mirror of
https://github.com/openbsd/src.git
synced 2025-01-10 06:47:55 -08:00
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
This commit is contained in:
parent
0bd8f2fbe1
commit
324e76047b
@ -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";
|
||||
|
Loading…
Reference in New Issue
Block a user