diff options
author | Ray Lai <ray@cvs.openbsd.org> | 2007-06-27 03:29:32 +0000 |
---|---|---|
committer | Ray Lai <ray@cvs.openbsd.org> | 2007-06-27 03:29:32 +0000 |
commit | 2f3705d1a955d7d70e338187df216101371dba94 (patch) | |
tree | 78e1f483ae0017cb999bb589774276ebf86b39d7 /usr.bin/checknr | |
parent | 5dde4b8204eabca5cfd391ce43911c60e7bbb055 (diff) |
From Tobias Stoeckmann:
- Fix a file descriptor leak.
- Print usage if -a and -c flags are passed a zero-length string.
OK millert and moritz
Diffstat (limited to 'usr.bin/checknr')
-rw-r--r-- | usr.bin/checknr/checknr.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/usr.bin/checknr/checknr.c b/usr.bin/checknr/checknr.c index 413acbef08d..f8aad7d6241 100644 --- a/usr.bin/checknr/checknr.c +++ b/usr.bin/checknr/checknr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: checknr.c,v 1.14 2005/03/29 23:46:19 jaredy Exp $ */ +/* $OpenBSD: checknr.c,v 1.15 2007/06/27 03:29:31 ray Exp $ */ /* $NetBSD: checknr.c,v 1.4 1995/03/26 04:10:19 glass Exp $ */ /* @@ -40,7 +40,7 @@ static const char copyright[] = #if 0 static const char sccsid[] = "@(#)checknr.c 8.1 (Berkeley) 6/6/93"; #else -static const char rcsid[] = "$OpenBSD: checknr.c,v 1.14 2005/03/29 23:46:19 jaredy Exp $"; +static const char rcsid[] = "$OpenBSD: checknr.c,v 1.15 2007/06/27 03:29:31 ray Exp $"; #endif #endif /* not lint */ @@ -208,7 +208,7 @@ main(int argc, char *argv[]) /* -a: add pairs of macros */ case 'a': i = strlen(argv[1]) - 2; - if (i % 6 != 0) + if (i == 0 || i % 6 != 0) usage(); /* look for empty macro slots */ for (i=0; br[i].opbr; i++) @@ -231,7 +231,7 @@ main(int argc, char *argv[]) /* -c: add known commands */ case 'c': i = strlen(argv[1]) - 2; - if (i % 3 != 0) + if (i == 0 || i % 3 != 0) usage(); for (cp=argv[1]+3; cp[-1]; cp += 3) { if (cp[2] && cp[2] != '.') @@ -264,8 +264,10 @@ main(int argc, char *argv[]) f = fopen(cfilename, "r"); if (f == NULL) warn("%s", cfilename); - else + else { process(f); + fclose(f); + } } } else { cfilename = "stdin"; |