summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-05-31 21:33:05 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-05-31 21:33:05 +0000
commit7bbc70ff8f5d035b748582648b0f6f2f2b3ab9aa (patch)
treeba268e925d0a345e2f3b78c85cbd3f1fcae1b131
parent686f7819ca5d476b6e7dd6c2b528bc847057cc62 (diff)
use strtonum() instead of atoi() to parse the device address
(from 1 - USB_MAX_DEVICES, not 0- as submitted) from Gleydson Soares
-rw-r--r--usr.sbin/usbdevs/usbdevs.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.sbin/usbdevs/usbdevs.c b/usr.sbin/usbdevs/usbdevs.c
index 24af6e9b7ec..99fc276c90a 100644
--- a/usr.sbin/usbdevs/usbdevs.c
+++ b/usr.sbin/usbdevs/usbdevs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usbdevs.c,v 1.18 2010/04/02 05:46:21 ckuethe Exp $ */
+/* $OpenBSD: usbdevs.c,v 1.19 2010/05/31 21:33:04 deraadt Exp $ */
/* $NetBSD: usbdevs.c,v 1.19 2002/02/21 00:34:31 christos Exp $ */
/*
@@ -267,13 +267,16 @@ main(int argc, char **argv)
int ch, i, f;
char buf[50];
char *dev = 0;
+ const char *errstr;
int addr = 0;
int ncont;
while ((ch = getopt(argc, argv, "a:df:v?")) != -1) {
switch (ch) {
case 'a':
- addr = atoi(optarg);
+ addr = strtonum(optarg, 1, USB_MAX_DEVICES, &errstr);
+ if (errstr)
+ errx(1, "addr %s", errstr);
break;
case 'd':
showdevs++;