summaryrefslogtreecommitdiff
path: root/usr.bin/unifdef
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-18 18:28:39 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-04-18 18:28:39 +0000
commit82e40d211902d486d2871a1bc691d1768927efd5 (patch)
tree73caeece4da00dad32b1e62383474772aae90893 /usr.bin/unifdef
parenta15dfcc7862a97d34cf8fed2bb1292c14721e771 (diff)
Convert many atoi() calls to strtonum(), adding range checks and failure
handling along the way. Reviews by Brendan MacDonell, Jeremy Devenport, florian, doug, millert
Diffstat (limited to 'usr.bin/unifdef')
-rw-r--r--usr.bin/unifdef/unifdef.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.bin/unifdef/unifdef.c b/usr.bin/unifdef/unifdef.c
index 89df19740aa..fa751572814 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: miod $\n"
+ "@(#) $Author: deraadt $\n"
"@(#) $URL: http://dotat.at/prog/unifdef $\n"
;
@@ -252,6 +252,7 @@ static const char *xstrdup(const char *, const char *);
int
main(int argc, char *argv[])
{
+ const char *errstr;
int opt;
while ((opt = getopt(argc, argv, "i:D:U:f:I:M:o:x:bBcdehKklmnsStV")) != -1)
@@ -332,9 +333,9 @@ main(int argc, char *argv[])
version();
break;
case 'x':
- exitmode = atoi(optarg);
- if(exitmode < 0 || exitmode > 2)
- usage();
+ exitmode = strtonum(optarg, 0, 2, &errstr);
+ if (errstr)
+ errx(1, "-x %s: %s", optarg, errstr);
break;
default:
usage();