diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2000-06-30 16:00:30 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2000-06-30 16:00:30 +0000 |
commit | b643bb9badf4a995d989b8daf3e33ba8ee6ffda2 (patch) | |
tree | 87720e8aa60a5b4230d0072dfd2b3d422d7dd1cd /usr.bin/mail | |
parent | 46239127052c30fac93140fbe021cdd151fdac8a (diff) |
warnx?/errx? paranoia (use "%s" not a bare string unless it is a
constant). These are not security holes but it is worth fixing
them anyway both for robustness and so folks looking for examples
in the tree are not misled into doing something potentially dangerous.
Furthermore, it is a bad idea to assume that pathnames will not
include '%' in them and that error routines don't return strings
with '%' in them (especially in light of the possibility of locales).
Diffstat (limited to 'usr.bin/mail')
-rw-r--r-- | usr.bin/mail/aux.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/cmd1.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/cmd3.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/collect.c | 14 | ||||
-rw-r--r-- | usr.bin/mail/edit.c | 16 | ||||
-rw-r--r-- | usr.bin/mail/lex.c | 14 | ||||
-rw-r--r-- | usr.bin/mail/main.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/names.c | 14 | ||||
-rw-r--r-- | usr.bin/mail/popen.c | 6 | ||||
-rw-r--r-- | usr.bin/mail/quit.c | 36 | ||||
-rw-r--r-- | usr.bin/mail/send.c | 16 |
11 files changed, 70 insertions, 70 deletions
diff --git a/usr.bin/mail/aux.c b/usr.bin/mail/aux.c index f82bd763a69..f418991eebc 100644 --- a/usr.bin/mail/aux.c +++ b/usr.bin/mail/aux.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aux.c,v 1.14 2000/04/25 16:42:22 millert Exp $ */ +/* $OpenBSD: aux.c,v 1.15 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: aux.c,v 1.14 2000/04/25 16:42:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: aux.c,v 1.15 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -294,7 +294,7 @@ source(v) if ((cp = expand(*arglist)) == NULL) return(1); if ((fi = Fopen(cp, "r")) == NULL) { - warn(cp); + warn("%s", cp); return(1); } if (ssp >= NOFILE - 1) { diff --git a/usr.bin/mail/cmd1.c b/usr.bin/mail/cmd1.c index 2e83ef729f3..b53a92c40cc 100644 --- a/usr.bin/mail/cmd1.c +++ b/usr.bin/mail/cmd1.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd1.c,v 1.15 2000/04/26 15:47:29 millert Exp $ */ +/* $OpenBSD: cmd1.c,v 1.16 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: cmd1.c,v 1.9 1997/07/09 05:29:48 mikel Exp $ */ /*- @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmd1.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd1.c,v 1.15 2000/04/26 15:47:29 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmd1.c,v 1.16 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -335,7 +335,7 @@ type1(msgvec, doign, page) cp = _PATH_MORE; obuf = Popen(cp, "w"); if (obuf == NULL) { - warn(cp); + warn("%s", cp); obuf = stdout; } else (void)signal(SIGPIPE, brokpipe); diff --git a/usr.bin/mail/cmd3.c b/usr.bin/mail/cmd3.c index f02e27e3eb4..19f2dfa9200 100644 --- a/usr.bin/mail/cmd3.c +++ b/usr.bin/mail/cmd3.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd3.c,v 1.11 2000/04/25 16:42:22 millert Exp $ */ +/* $OpenBSD: cmd3.c,v 1.12 2000/06/30 16:00:16 millert Exp $ */ /* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: cmd3.c,v 1.11 2000/04/25 16:42:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: cmd3.c,v 1.12 2000/06/30 16:00:16 millert Exp $"; #endif #endif /* not lint */ @@ -188,7 +188,7 @@ schdir(v) if ((cp = expand(*arglist)) == NULL) return(1); if (chdir(cp) < 0) { - warn(cp); + warn("%s", cp); return(1); } return(0); diff --git a/usr.bin/mail/collect.c b/usr.bin/mail/collect.c index 1ad6274da1e..4e39ded1d9e 100644 --- a/usr.bin/mail/collect.c +++ b/usr.bin/mail/collect.c @@ -1,4 +1,4 @@ -/* $OpenBSD: collect.c,v 1.18 2000/04/26 15:47:30 millert Exp $ */ +/* $OpenBSD: collect.c,v 1.19 2000/06/30 16:00:17 millert Exp $ */ /* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94"; #else -static char rcsid[] = "$OpenBSD: collect.c,v 1.18 2000/04/26 15:47:30 millert Exp $"; +static char rcsid[] = "$OpenBSD: collect.c,v 1.19 2000/06/30 16:00:17 millert Exp $"; #endif #endif /* not lint */ @@ -123,7 +123,7 @@ collect(hp, printheaders) "%s/mail.RsXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (collf = Fdopen(fd, "w+")) == NULL) { - warn(tempname); + warn("%s", tempname); goto err; } (void)rm(tempname); @@ -305,7 +305,7 @@ cont: break; } if ((fbuf = Fopen(cp, "r")) == NULL) { - warn(cp); + warn("%s", cp); break; } printf("\"%s\" ", cp); @@ -465,7 +465,7 @@ exwrite(name, fp, f) lc++; (void)putc(c, of); if (ferror(of)) { - warn(name); + warn("%s", name); (void)Fclose(of); return(-1); } @@ -516,7 +516,7 @@ mespipe(fp, cmd) "%s/mail.ReXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (nf = Fdopen(fd, "w+")) == NULL) { - warn(tempname); + warn("%s", tempname); goto out; } (void)rm(tempname); @@ -590,7 +590,7 @@ forward(ms, fp, fn, f) touch(mp); printf(" %d", *msgvec); if (sendmessage(mp, fp, ig, tabst) < 0) { - warn(fn); + warn("%s", fn); return(-1); } } diff --git a/usr.bin/mail/edit.c b/usr.bin/mail/edit.c index 43e7095b13e..04e7ace6ea5 100644 --- a/usr.bin/mail/edit.c +++ b/usr.bin/mail/edit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: edit.c,v 1.7 1997/11/14 00:23:45 millert Exp $ */ +/* $OpenBSD: edit.c,v 1.8 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: edit.c,v 1.5 1996/06/08 19:48:20 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)edit.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: edit.c,v 1.7 1997/11/14 00:23:45 millert Exp $"; +static char rcsid[] = "$OpenBSD: edit.c,v 1.8 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -161,11 +161,11 @@ run_editor(fp, size, type, readonly) "%s/mail.ReXXXXXXXXXX", tmpdir); if ((t = mkstemp(tempname)) == -1 || (nf = Fdopen(t, "w")) == NULL) { - warn(tempname); + warn("%s", tempname); goto out; } if (readonly && fchmod(t, 0400) == -1) { - warn(tempname); + warn("%s", tempname); (void)rm(tempname); goto out; } @@ -182,13 +182,13 @@ run_editor(fp, size, type, readonly) modtime = statb.st_mtime; if (ferror(nf)) { (void)Fclose(nf); - warn(tempname); + warn("%s", tempname); (void)rm(tempname); nf = NULL; goto out; } if (Fclose(nf) < 0) { - warn(tempname); + warn("%s", tempname); (void)rm(tempname); nf = NULL; goto out; @@ -209,7 +209,7 @@ run_editor(fp, size, type, readonly) goto out; } if (stat(tempname, &statb) < 0) { - warn(tempname); + warn("%s", tempname); goto out; } if (modtime == statb.st_mtime) { @@ -220,7 +220,7 @@ run_editor(fp, size, type, readonly) * Now switch to new file. */ if ((nf = Fopen(tempname, "a+")) == NULL) { - warn(tempname); + warn("%s", tempname); (void)rm(tempname); goto out; } diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c index b1405843e5f..5b6099013f3 100644 --- a/usr.bin/mail/lex.c +++ b/usr.bin/mail/lex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lex.c,v 1.19 2000/04/25 16:42:22 millert Exp $ */ +/* $OpenBSD: lex.c,v 1.20 2000/06/30 16:00:19 millert Exp $ */ /* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: lex.c,v 1.19 2000/04/25 16:42:22 millert Exp $"; +static char rcsid[] = "$OpenBSD: lex.c,v 1.20 2000/06/30 16:00:19 millert Exp $"; #endif #endif /* not lint */ @@ -79,7 +79,7 @@ setfile(name) if ((ibuf = Fopen(name, "r")) == NULL) { if (!isedit && errno == ENOENT) goto nomail; - warn(name); + warn("%s", name); return(-1); } @@ -93,7 +93,7 @@ setfile(name) case S_IFDIR: (void)Fclose(ibuf); errno = EISDIR; - warn(name); + warn("%s", name); return(-1); case S_IFREG: @@ -102,7 +102,7 @@ setfile(name) default: (void)Fclose(ibuf); errno = EINVAL; - warn(name); + warn("%s", name); return(-1); } @@ -143,10 +143,10 @@ setfile(name) "%s/mail.RxXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (otf = fdopen(fd, "w")) == NULL) - err(1, tempname); + err(1, "%s", tempname); (void)fcntl(fileno(otf), F_SETFD, 1); if ((itf = fopen(tempname, "r")) == NULL) - err(1, tempname); + err(1, "%s", tempname); (void)fcntl(fileno(itf), F_SETFD, 1); (void)rm(tempname); setptr(ibuf, 0); diff --git a/usr.bin/mail/main.c b/usr.bin/mail/main.c index d413952827e..94e262fa549 100644 --- a/usr.bin/mail/main.c +++ b/usr.bin/mail/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.11 1998/09/27 21:16:42 millert Exp $ */ +/* $OpenBSD: main.c,v 1.12 2000/06/30 16:00:19 millert Exp $ */ /* $NetBSD: main.c,v 1.7 1997/05/13 06:15:57 mikel Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 4/20/95"; #else -static char rcsid[] = "$OpenBSD: main.c,v 1.11 1998/09/27 21:16:42 millert Exp $"; +static char rcsid[] = "$OpenBSD: main.c,v 1.12 2000/06/30 16:00:19 millert Exp $"; #endif #endif /* not lint */ @@ -107,7 +107,7 @@ main(argc, argv) */ Tflag = optarg; if ((i = creat(Tflag, 0600)) < 0) - err(1, Tflag); + err(1, "%s", Tflag); (void)close(i); break; case 'u': diff --git a/usr.bin/mail/names.c b/usr.bin/mail/names.c index 70d2269f0b3..b9cce0f469f 100644 --- a/usr.bin/mail/names.c +++ b/usr.bin/mail/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.10 2000/03/23 19:32:13 millert Exp $ */ +/* $OpenBSD: names.c,v 1.11 2000/06/30 16:00:16 millert Exp $ */ /* $NetBSD: names.c,v 1.5 1996/06/08 19:48:32 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)names.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: names.c,v 1.10 2000/03/23 19:32:13 millert Exp $"; +static char rcsid[] = "$OpenBSD: names.c,v 1.11 2000/06/30 16:00:16 millert Exp $"; #endif #endif /* not lint */ @@ -260,14 +260,14 @@ outof(names, fo, hp) "%s/mail.ReXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (fout = Fdopen(fd, "a")) == NULL) { - warn(tempname); + warn("%s", tempname); senderr++; goto cant; } image = open(tempname, O_RDWR); (void)rm(tempname); if (image < 0) { - warn(tempname); + warn("%s", tempname); senderr++; (void)Fclose(fout); goto cant; @@ -281,7 +281,7 @@ outof(names, fo, hp) (void)putc('\n', fout); (void)fflush(fout); if (ferror(fout)) - warn(tempname); + warn("%s", tempname); (void)Fclose(fout); } @@ -319,7 +319,7 @@ outof(names, fo, hp) } else { int f; if ((fout = Fopen(fname, "a")) == NULL) { - warn(fname); + warn("%s", fname); senderr++; goto cant; } @@ -339,7 +339,7 @@ outof(names, fo, hp) (void)putc(c, fout); if (ferror(fout)) { senderr++; - warn(fname); + warn("%s", fname); } (void)Fclose(fout); (void)Fclose(fin); diff --git a/usr.bin/mail/popen.c b/usr.bin/mail/popen.c index 82664f8cc0c..e93e6c36564 100644 --- a/usr.bin/mail/popen.c +++ b/usr.bin/mail/popen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popen.c,v 1.23 1998/09/27 21:16:42 millert Exp $ */ +/* $OpenBSD: popen.c,v 1.24 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: popen.c,v 1.6 1997/05/13 06:48:42 mikel Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: popen.c,v 1.23 1998/09/27 21:16:42 millert Exp $"; +static char rcsid[] = "$OpenBSD: popen.c,v 1.24 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -263,7 +263,7 @@ start_command(cmd, nset, infd, outfd, a0, a1, a2) argv[i] = NULL; prepare_child(nset, infd, outfd); execvp(argv[0], argv); - warn(argv[0]); + warn("%s", argv[0]); _exit(1); } return(pid); diff --git a/usr.bin/mail/quit.c b/usr.bin/mail/quit.c index 310fc71a753..3119f691731 100644 --- a/usr.bin/mail/quit.c +++ b/usr.bin/mail/quit.c @@ -1,4 +1,4 @@ -/* $OpenBSD: quit.c,v 1.12 2000/04/26 15:47:31 millert Exp $ */ +/* $OpenBSD: quit.c,v 1.13 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: quit.c,v 1.6 1996/12/28 07:11:07 tls Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)quit.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: quit.c,v 1.12 2000/04/26 15:47:31 millert Exp $"; +static char rcsid[] = "$OpenBSD: quit.c,v 1.13 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -221,13 +221,13 @@ quit() "%s/mail.RmXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) { - warn(tempname); + warn("%s", tempname); (void)Fclose(fbuf); spool_unlock(); return; } if ((ibuf = Fopen(tempname, "r")) == NULL) { - warn(tempname); + warn("%s", tempname); (void)rm(tempname); (void)Fclose(obuf); (void)Fclose(fbuf); @@ -241,7 +241,7 @@ quit() (void)Fclose(abuf); } if (ferror(obuf)) { - warn(tempname); + warn("%s", tempname); (void)Fclose(ibuf); (void)Fclose(obuf); (void)Fclose(fbuf); @@ -251,7 +251,7 @@ quit() (void)Fclose(obuf); (void)close(creat(mbox, 0600)); if ((obuf = Fopen(mbox, "r+")) == NULL) { - warn(mbox); + warn("%s", mbox); (void)Fclose(ibuf); (void)Fclose(fbuf); spool_unlock(); @@ -260,7 +260,7 @@ quit() } else { if ((obuf = Fopen(mbox, "a")) == NULL) { - warn(mbox); + warn("%s", mbox); (void)Fclose(fbuf); spool_unlock(); return; @@ -270,7 +270,7 @@ quit() for (mp = &message[0]; mp < &message[msgCount]; mp++) if (mp->m_flag & MBOX) if (sendmessage(mp, obuf, saveignore, NULL) < 0) { - warn(mbox); + warn("%s", mbox); (void)Fclose(ibuf); (void)Fclose(obuf); (void)Fclose(fbuf); @@ -298,7 +298,7 @@ quit() } trunc(obuf); if (ferror(obuf)) { - warn(mbox); + warn("%s", mbox); (void)Fclose(obuf); (void)Fclose(fbuf); spool_unlock(); @@ -371,7 +371,7 @@ writeback(res) p = 0; if ((obuf = Fopen(mailname, "r+")) == NULL) { - warn(mailname); + warn("%s", mailname); return(-1); } #ifndef APPEND @@ -383,7 +383,7 @@ writeback(res) if ((mp->m_flag&MPRESERVE)||(mp->m_flag&MTOUCH)==0) { p++; if (sendmessage(mp, obuf, NULL, NULL) < 0) { - warn(mailname); + warn("%s", mailname); (void)Fclose(obuf); return(-1); } @@ -396,7 +396,7 @@ writeback(res) fflush(obuf); trunc(obuf); if (ferror(obuf)) { - warn(mailname); + warn("%s", mailname); (void)Fclose(obuf); return(-1); } @@ -457,12 +457,12 @@ edstop() tmpdir); if ((fd = mkstemp(tempname)) == -1 || (obuf = Fdopen(fd, "w")) == NULL) { - warn(tempname); + warn("%s", tempname); relsesigs(); reset(0); } if ((ibuf = Fopen(mailname, "r")) == NULL) { - warn(mailname); + warn("%s", mailname); (void)Fclose(obuf); (void)rm(tempname); relsesigs(); @@ -474,7 +474,7 @@ edstop() (void)Fclose(ibuf); (void)Fclose(obuf); if ((ibuf = Fopen(tempname, "r")) == NULL) { - warn(tempname); + warn("%s", tempname); (void)rm(tempname); relsesigs(); reset(0); @@ -484,7 +484,7 @@ edstop() printf("\"%s\" ", mailname); fflush(stdout); if ((obuf = Fopen(mailname, "r+")) == NULL) { - warn(mailname); + warn("%s", mailname); relsesigs(); reset(0); } @@ -495,7 +495,7 @@ edstop() continue; c++; if (sendmessage(mp, obuf, NULL, NULL) < 0) { - warn(mailname); + warn("%s", mailname); relsesigs(); reset(0); } @@ -508,7 +508,7 @@ edstop() } fflush(obuf); if (ferror(obuf)) { - warn(mailname); + warn("%s", mailname); relsesigs(); reset(0); } diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c index df12fe6d35e..fde6063e667 100644 --- a/usr.bin/mail/send.c +++ b/usr.bin/mail/send.c @@ -1,4 +1,4 @@ -/* $OpenBSD: send.c,v 1.10 2000/04/26 15:47:31 millert Exp $ */ +/* $OpenBSD: send.c,v 1.11 2000/06/30 16:00:18 millert Exp $ */ /* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */ /* @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: send.c,v 1.10 2000/04/26 15:47:31 millert Exp $"; +static char rcsid[] = "$OpenBSD: send.c,v 1.11 2000/06/30 16:00:18 millert Exp $"; #endif #endif /* not lint */ @@ -385,7 +385,7 @@ mail1(hp, printheaders) else cp = _PATH_SENDMAIL; execv(cp, namelist); - warn(cp); + warn("%s", cp); _exit(1); } if (value("verbose") != NULL) @@ -439,11 +439,11 @@ infix(hp, fi) "%s/mail.RsXXXXXXXXXX", tmpdir); if ((fd = mkstemp(tempname)) == -1 || (nfo = Fdopen(fd, "w")) == NULL) { - warn(tempname); + warn("%s", tempname); return(fi); } if ((nfi = Fopen(tempname, "r")) == NULL) { - warn(tempname); + warn("%s", tempname); (void)Fclose(nfo); (void)rm(tempname); return(fi); @@ -462,7 +462,7 @@ infix(hp, fi) } (void)fflush(nfo); if (ferror(nfo)) { - warn(tempname); + warn("%s", tempname); (void)Fclose(nfo); (void)Fclose(nfi); rewind(fi); @@ -550,7 +550,7 @@ savemail(name, fi) time_t now; if ((fo = Fopen(name, "a")) == NULL) { - warn(name); + warn("%s", name); return(-1); } (void)time(&now); @@ -560,7 +560,7 @@ savemail(name, fi) (void)putc('\n', fo); (void)fflush(fo); if (ferror(fo)) - warn(name); + warn("%s", name); (void)Fclose(fo); rewind(fi); return(0); |