diff options
author | charnier <charnier@FreeBSD.org> | 1997-06-23 06:52:13 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-06-23 06:52:13 +0000 |
commit | 2d49da06e0527f3ea89c74a20917a80b12f378b4 (patch) | |
tree | 0a21d04a14509de96671fc19025c96105fdbee3a /usr.bin/calendar/io.c | |
parent | 14698cd80ae1af087e716da460feb3a02c3b4017 (diff) | |
download | FreeBSD-src-2d49da06e0527f3ea89c74a20917a80b12f378b4.zip FreeBSD-src-2d49da06e0527f3ea89c74a20917a80b12f378b4.tar.gz |
Use err(3). Abort if strdup() returns NULL.
Diffstat (limited to 'usr.bin/calendar/io.c')
-rw-r--r-- | usr.bin/calendar/io.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/usr.bin/calendar/io.c b/usr.bin/calendar/io.c index 014a805..9634dac 100644 --- a/usr.bin/calendar/io.c +++ b/usr.bin/calendar/io.c @@ -29,6 +29,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ #ifndef lint @@ -112,14 +114,16 @@ cal() if (strncasecmp(buf, "Easter=", 7) == 0 && buf[7]) { if (neaster.name != NULL) free(neaster.name); - neaster.name = strdup(buf + 7); + if ((neaster.name = strdup(buf + 7)) == NULL) + errx(1, "cannot allocate memory"); neaster.len = strlen(buf + 7); continue; } if (strncasecmp(buf, "Paskha=", 7) == 0 && buf[7]) { if (npaskha.name != NULL) free(npaskha.name); - npaskha.name = strdup(buf + 7); + if ((npaskha.name = strdup(buf + 7)) == NULL) + errx(1, "cannot allocate memory"); npaskha.len = strlen(buf + 7); continue; } @@ -259,20 +263,19 @@ opencal() (void)close(pdes[0]); uid = geteuid(); if (setuid(getuid()) < 0) { - fprintf(stderr, "calendar: first setuid failed\n"); + warnx("first setuid failed"); _exit(1); }; if (setgid(getegid()) < 0) { - fprintf(stderr, "calendar: setgid failed\n"); + warnx("setgid failed"); _exit(1); } if (setuid(uid) < 0) { - fprintf(stderr, "calendar: setuid failed\n"); + warnx("setuid failed"); _exit(1); } execl(_PATH_CPP, "cpp", "-P", "-I.", _PATH_INCLUDE, NULL); - (void)fprintf(stderr, - "calendar: execl: %s: %s.\n", _PATH_CPP, strerror(errno)); + warn(_PATH_CPP); _exit(1); } /* parent -- set stdin to pipe output */ @@ -322,21 +325,20 @@ closecal(fp) (void)close(pdes[1]); uid = geteuid(); if (setuid(getuid()) < 0) { - fprintf(stderr, "calendar: setuid failed\n"); + warnx("setuid failed"); _exit(1); }; if (setgid(getegid()) < 0) { - fprintf(stderr, "calendar: setgid failed\n"); + warnx("setgid failed"); _exit(1); } if (setuid(uid) < 0) { - fprintf(stderr, "calendar: setuid failed\n"); + warnx("setuid failed"); _exit(1); } execl(_PATH_SENDMAIL, "sendmail", "-i", "-t", "-F", "\"Reminder Service\"", NULL); - (void)fprintf(stderr, - "calendar: %s: %s.\n", _PATH_SENDMAIL, strerror(errno)); + warn(_PATH_SENDMAIL); _exit(1); } /* parent -- write to pipe input */ @@ -352,4 +354,3 @@ done: (void)fclose(fp); (void)unlink(path); while (wait(&status) >= 0); } - |