From 7bbc70ff8f5d035b748582648b0f6f2f2b3ab9aa Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Mon, 31 May 2010 21:33:05 +0000 Subject: use strtonum() instead of atoi() to parse the device address (from 1 - USB_MAX_DEVICES, not 0- as submitted) from Gleydson Soares --- usr.sbin/usbdevs/usbdevs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'usr.sbin') 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++; -- cgit v1.2.3