From: Tomas Mraz Date: Fri, 11 Mar 2011 13:02:35 +0000 (+0100) Subject: Add missing check for stat() return value. X-Git-Tag: cronie1.4.7~12 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=969e3e934ce2af5529f1383ab68507cdcf1fd53e;p=cronie Add missing check for stat() return value. --- diff --git a/src/misc.c b/src/misc.c index 8ccda51..dbe4952 100644 --- a/src/misc.c +++ b/src/misc.c @@ -235,7 +235,10 @@ void set_cron_cwd(void) { perror(SPOOL_DIR); if (OK == mkdir(SPOOL_DIR, 0700)) { fprintf(stderr, "%s: created\n", SPOOL_DIR); - stat(SPOOL_DIR, &sb); + if (stat(SPOOL_DIR, &sb) < OK) { + perror("stat retry"); + exit(ERROR_EXIT); + } } else { fprintf(stderr, "%s: ", SPOOL_DIR); @@ -250,7 +253,7 @@ void set_cron_cwd(void) { if (grp != NULL) { if (sb.st_gid != grp->gr_gid) if (chown(SPOOL_DIR, -1, grp->gr_gid) == -1) { - fprintf(stderr, "chdir %s failed: %s\n", SPOOL_DIR, + fprintf(stderr, "chown %s failed: %s\n", SPOOL_DIR, strerror(errno)); exit(ERROR_EXIT); }