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/indent/indent.c | |
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/indent/indent.c')
-rw-r--r-- | usr.bin/indent/indent.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c index e229d6797af..50a75cbf32f 100644 --- a/usr.bin/indent/indent.c +++ b/usr.bin/indent/indent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: indent.c,v 1.6 1999/05/19 03:17:16 alex Exp $ */ +/* $OpenBSD: indent.c,v 1.7 2000/06/30 16:00:15 millert Exp $ */ /* * Copyright (c) 1985 Sun Microsystems, Inc. @@ -45,7 +45,7 @@ char copyright[] = #ifndef lint /*static char sccsid[] = "from: @(#)indent.c 5.16 (Berkeley) 2/26/91";*/ -static char rcsid[] = "$OpenBSD: indent.c,v 1.6 1999/05/19 03:17:16 alex Exp $"; +static char rcsid[] = "$OpenBSD: indent.c,v 1.7 2000/06/30 16:00:15 millert Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -190,7 +190,7 @@ main(argc, argv) in_name = argv[i]; /* remember name of input file */ input = fopen(in_name, "r"); if (input == NULL) /* check for open error */ - err(1, in_name); + err(1, "%s", in_name); continue; } else if (output == 0) { /* we have the output file */ @@ -200,7 +200,7 @@ main(argc, argv) errx(1, "input and output files must be different"); output = fopen(out_name, "w"); if (output == NULL) /* check for create error */ - err(1, out_name); + err(1, "%s", out_name); continue; } errx(1, "unknown parameter: %s", argv[i]); @@ -1155,23 +1155,23 @@ bakcopy() /* copy in_name to backup file */ bakchn = creat(bakfile, 0600); if (bakchn < 0) - err(1, bakfile); + err(1, "%s", bakfile); while ((n = read(fileno(input), buff, sizeof buff)) > 0) if (write(bakchn, buff, n) != n) - err(1, bakfile); + err(1, "%s", bakfile); if (n < 0) - err(1, in_name); + err(1, "%s", in_name); close(bakchn); fclose(input); /* re-open backup file as the input file */ input = fopen(bakfile, "r"); if (input == NULL) - err(1, bakfile); + err(1, "%s", bakfile); /* now the original input file will be the output */ output = fopen(in_name, "w"); if (output == NULL) { unlink(bakfile); - err(1, in_name); + err(1, "%s", in_name); } } |