aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/proctitle.c11
-rw-r--r--src/inetd-bi.c9
-rw-r--r--src/progman.c23
-rw-r--r--src/sysvinit.c1
-rw-r--r--src/userprivs.c12
-rw-r--r--src/utmp.c3
6 files changed, 31 insertions, 28 deletions
diff --git a/lib/proctitle.c b/lib/proctitle.c
index 2ec7d38..53f9fdc 100644
--- a/lib/proctitle.c
+++ b/lib/proctitle.c
@@ -139,22 +139,21 @@ void
mf_proctitle_format (const char *fmt, ...)
{
va_list ap;
- char *tmp = NULL;
-
+ char *tmp;
+ int rc;
if (!orig_argc)
return;
va_start (ap, fmt);
- vasprintf (&tmp, fmt, ap);
+ rc = vasprintf (&tmp, fmt, ap);
va_end (ap);
- if (tmp) {
+ if (rc > 0) {
free (proctitle_buffer);
#if __FreeBSD__ >= 4
/* On FreeBSD the process name is prepended automatically */
proctitle_buffer = tmp;
#else
/* Otherwise we need to do that manually */
- asprintf (&proctitle_buffer, "%s: %s", __progname, tmp);
- if (proctitle_buffer)
+ if (asprintf (&proctitle_buffer, "%s: %s", __progname, tmp) > 0)
free (tmp);
else
proctitle_buffer = tmp;
diff --git a/src/inetd-bi.c b/src/inetd-bi.c
index a579fbb..e472390 100644
--- a/src/inetd-bi.c
+++ b/src/inetd-bi.c
@@ -93,7 +93,8 @@ static void
time_stream (int fd, struct component const *comp)
{
unsigned long result = time_since_1900 ();
- write (fd, (char *) &result, sizeof result);
+ if (write (fd, (char *) &result, sizeof result) == -1)
+ logmsg (LOG_ERR, "write: %s", strerror (errno));
}
static void
@@ -118,7 +119,8 @@ daytime_stream (int fd, struct component const *comp)
time (&now);
sprintf (buffer, "%.24s\r\n", ctime (&now));
- write (fd, buffer, strlen (buffer));
+ if (write (fd, buffer, strlen (buffer)) == -1)
+ logmsg (LOG_ERR, "write: %s", strerror (errno));
}
static void
@@ -251,7 +253,8 @@ qotd_stream (int fd, struct component const *comp)
{
char text[QOTD_MAX];
size_t len = qotd_read (text);
- write (fd, text, len);
+ if (write (fd, text, len) == -1)
+ logmsg (LOG_ERR, "write: %s", strerror (errno));
}
static void
diff --git a/src/progman.c b/src/progman.c
index c9741d5..e666535 100644
--- a/src/progman.c
+++ b/src/progman.c
@@ -393,7 +393,13 @@ redirect_to_file (struct prog *master, int stream)
/* Fix file ownership */
if (master->v.p.comp->privs.user
&& (pw = getpwnam (master->v.p.comp->privs.user)) != NULL)
- chown (master->v.p.comp->redir[stream].v.file, pw->pw_uid, pw->pw_gid);
+ {
+ if (chown (master->v.p.comp->redir[stream].v.file,
+ pw->pw_uid, pw->pw_gid))
+ logmsg (LOG_ERR, "chown %s: %s",
+ master->v.p.comp->redir[stream].v.file,
+ strerror (errno));
+ }
return fd;
}
@@ -402,7 +408,7 @@ close_fds (fd_set *fdset)
{
int i;
- for (i = getmaxfd (); i >= 0; i--)
+ for (i = FD_SETSIZE-1; i >= 0; i--)
{
if (fdset && FD_ISSET (i, fdset))
continue;
@@ -441,7 +447,12 @@ open_redirector (struct prog *master, int stream)
break;
}
- pipe (p);
+ if (pipe (p))
+ {
+ logmsg (LOG_CRIT, "pipe: %s", strerror (errno));
+ return -1;
+ }
+
switch (pid = fork ())
{
case 0:
@@ -2445,8 +2456,7 @@ progman_dump_stats (const char *filename)
struct prog *prog;
char *tmpfile = NULL;
- asprintf (&tmpfile, "%s.%lu", filename, (unsigned long) getpid ());
- if (!tmpfile)
+ if (asprintf (&tmpfile, "%s.%lu", filename, (unsigned long) getpid ()) == -1)
{
logmsg (LOG_ERR, "%s", strerror (ENOMEM));
return;
@@ -2490,6 +2500,9 @@ progman_dump_stats (const char *filename)
case pies_comp_pass_fd:
fbuf[fidx++] = 'P';
+
+ default:
+ break;
}
switch (prog->v.p.status)
diff --git a/src/sysvinit.c b/src/sysvinit.c
index 7e0dba6..1bf3a3b 100644
--- a/src/sysvinit.c
+++ b/src/sysvinit.c
@@ -364,7 +364,6 @@ envsetup ()
static void
sysvinit_setenv (char const *data, int size)
{
- char const *end;
int i, j;
while (size) {
diff --git a/src/userprivs.c b/src/userprivs.c
index e64162b..5f56ce9 100644
--- a/src/userprivs.c
+++ b/src/userprivs.c
@@ -26,18 +26,6 @@
#include <stdbool.h>
#include "pies.h"
-static bool
-str_eq (const void *elt1, const void *elt2)
-{
- return strcmp (elt1, elt2) == 0;
-}
-
-void
-str_dispose (const void *elt)
-{
- free ((void*)elt);
-}
-
struct grecs_list *
get_user_groups (struct grecs_list *init_list, const char *user)
{
diff --git a/src/utmp.c b/src/utmp.c
index d4452bc..6aed568 100644
--- a/src/utmp.c
+++ b/src/utmp.c
@@ -60,7 +60,8 @@ pies_updwtmpx (const char *wtmp_file, const UTMPX *ut)
int fd = open (wtmp_file, O_WRONLY|O_APPEND);
if (fd == -1)
return;
- write (fd, ut, sizeof (*ut));
+ if (write (fd, ut, sizeof (*ut)) == -1)
+ logmsg (LOG_ERR, "write %s: %s", wtmp_file, strerror (errno));
close (fd);
}
#endif

Return to:

Send suggestions and report system problems to the System administrator.