diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-02 04:10:51 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-08-02 04:10:51 +0000 |
commit | eb9184a174a8fb2f98f2f1418f87863716a5c115 (patch) | |
tree | 02b606fefe2b41782be054be7fdd586e53befba0 /gnu | |
parent | 3602a750205b32f442e2e132baa5b3e9a3c83349 (diff) |
$HOME paranoia: never use getenv("HOME") w/o checking for NULL and non-zero
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/usr.bin/binutils/readline/history.c | 12 | ||||
-rw-r--r-- | gnu/usr.sbin/mkisofs/mkisofs.c | 4 | ||||
-rw-r--r-- | gnu/usr.sbin/sendmail/sendmail/envelope.c | 10 |
3 files changed, 16 insertions, 10 deletions
diff --git a/gnu/usr.bin/binutils/readline/history.c b/gnu/usr.bin/binutils/readline/history.c index db18972ed87..64a2140374f 100644 --- a/gnu/usr.bin/binutils/readline/history.c +++ b/gnu/usr.bin/binutils/readline/history.c @@ -464,7 +464,7 @@ history_filename (filename) home = getenv ("HOME"); if (!home) - home = "."; + return (NULL); return_val = (char *)xmalloc (2 + strlen (home) + strlen (".history")); @@ -499,8 +499,10 @@ read_history_range (filename, from, to) int file, current_line; struct stat finfo; - input = history_filename (filename); - file = open (input, O_RDONLY, 0666); + if ((input = history_filename (filename))) + file = open (input, O_RDONLY, 0666); + else + file = -1; if ((file < 0) || (stat (input, &finfo) == -1)) @@ -584,7 +586,7 @@ history_truncate_file (fname, lines) struct stat finfo; filename = history_filename (fname); - if (stat (filename, &finfo) == -1) + if (!filename || stat (filename, &finfo) == -1) goto truncate_exit; file = open (filename, O_RDONLY, 0666); @@ -656,7 +658,7 @@ history_do_write (filename, nelements, overwrite) else mode = O_WRONLY | O_APPEND; - if ((file = open (output, mode, 0666)) == -1) + if (!output || (file = open (output, mode, 0666)) == -1) { if (output) free (output); diff --git a/gnu/usr.sbin/mkisofs/mkisofs.c b/gnu/usr.sbin/mkisofs/mkisofs.c index caf89542209..4f9eb51b9bd 100644 --- a/gnu/usr.sbin/mkisofs/mkisofs.c +++ b/gnu/usr.sbin/mkisofs/mkisofs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mkisofs.c,v 1.3 1999/11/29 21:53:15 d Exp $ */ +/* $OpenBSD: mkisofs.c,v 1.4 2000/08/02 04:10:45 millert Exp $ */ /* * Program mkisofs.c - generate iso9660 filesystem based upon directory * tree on hard disk. @@ -156,7 +156,7 @@ void FDECL1(read_rcfile, char *, appname) if (!rcfile) { pnt = getenv("HOME"); - if (pnt && strlen(pnt) + strlen(rcfn) + 2 <= sizeof(filename)) + if (pnt && *pnt && strlen(pnt) + strlen(rcfn) + 2 <= sizeof(filename)) { strcpy(filename, pnt); strcat(filename, "/"); diff --git a/gnu/usr.sbin/sendmail/sendmail/envelope.c b/gnu/usr.sbin/sendmail/sendmail/envelope.c index 696ea88d755..6f1e5eea293 100644 --- a/gnu/usr.sbin/sendmail/sendmail/envelope.c +++ b/gnu/usr.sbin/sendmail/sendmail/envelope.c @@ -833,9 +833,13 @@ setsender(from, e, delimptr, delimchar, internal) if (e->e_from.q_home == NULL) { e->e_from.q_home = getenv("HOME"); - if (e->e_from.q_home != NULL && - strcmp(e->e_from.q_home, "/") == 0) - e->e_from.q_home++; + if (e->e_from.q_home != NULL) + { + if (*e->e_from.q_home == '\0') + e->e_from.q_home = NULL; + else if (strcmp(e->e_from.q_home, "/") == 0) + e->e_from.q_home++; + } } e->e_from.q_uid = RealUid; e->e_from.q_gid = RealGid; |