diff options
author | 2015-04-18 18:28:36 +0000 | |
---|---|---|
committer | 2015-04-18 18:28:36 +0000 | |
commit | a47b6461a15f74beac188483616126ed5e987f93 (patch) | |
tree | 4453af12f02f369f89c8895bcfef1820fdb8576d /bin/systrace/systrace.c | |
parent | Delete the wrapper functions mdoc_meta(), man_meta(), mdoc_node(), (diff) | |
download | wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.tar.xz wireguard-openbsd-a47b6461a15f74beac188483616126ed5e987f93.zip |
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 'bin/systrace/systrace.c')
-rw-r--r-- | bin/systrace/systrace.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/bin/systrace/systrace.c b/bin/systrace/systrace.c index 2b701d9aa34..ce3b0ee90e1 100644 --- a/bin/systrace/systrace.c +++ b/bin/systrace/systrace.c @@ -1,4 +1,4 @@ -/* $OpenBSD: systrace.c,v 1.62 2015/01/16 00:19:12 deraadt Exp $ */ +/* $OpenBSD: systrace.c,v 1.63 2015/04/18 18:28:37 deraadt Exp $ */ /* * Copyright 2002 Niels Provos <provos@citi.umich.edu> * All rights reserved. @@ -647,6 +647,7 @@ main(int argc, char **argv) char **args; char *filename = NULL; char *policypath = NULL; + const char *errstr; struct timeval tv; pid_t pidattach = 0; int usex11 = 1; @@ -707,7 +708,8 @@ main(int argc, char **argv) case 'p': if (setcredentials) usage(); - if ((pidattach = atoi(optarg)) == 0) { + pidattach = strtonum(optarg, 1, INT_MAX, &errstr); + if (errstr) { warnx("bad pid: %s", optarg); usage(); } |