diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2015-10-03 20:12:54 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2015-10-03 20:12:54 +0000 |
commit | ee8b414bc40619821338e696eee76244dc7c8696 (patch) | |
tree | 4f05e9d8d7fa797592ab7aa0b59e4c503f1d379a /usr.bin | |
parent | 2def20d096a7cd09e00e276eab97a967deb3d3fd (diff) |
you can't edit stdin in place. check for this before the hack that
increments argc when run with no arguments, causing a read past the end
of argv.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/unifdef/unifdef.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c index bd414b8361f..83426e83b33 100644 --- a/usr.bin/unifdef/unifdef.c +++ b/usr.bin/unifdef/unifdef.c @@ -47,7 +47,7 @@ static const char copyright[] = #include "version.h" - "@(#) $Author: deraadt $\n" + "@(#) $Author: tedu $\n" "@(#) $URL: http://dotat.at/prog/unifdef $\n" ; @@ -350,6 +350,8 @@ main(int argc, char *argv[]) errx(2, "-o cannot be used with multiple input files"); if (argc > 1 && !inplace) errx(2, "multiple input files require -m or -M"); + if (argc == 0 && inplace) + errx(2, "can't edit stdin in place"); if (argc == 0) argc = 1; if (argc == 1 && !inplace && ofilename == NULL) |