svn commit: r273488 - head/usr.sbin/pciconf

Mark Johnston markj at FreeBSD.org
Wed Oct 22 23:35:57 UTC 2014


Author: markj
Date: Wed Oct 22 23:35:56 2014
New Revision: 273488
URL: https://svnweb.freebsd.org/changeset/base/273488

Log:
  Fix some buglets in the error-handling of getdevice(). In particular, report
  an error if the argument to pciconf -a doesn't have a unit number, rather
  than triggering an assertion failure.
  
  PR:		194506
  Reported by:	Anthony Cornehl <accornehl at gmail.com>
  Sponsored by:	EMC / Isilon Storage Division

Modified:
  head/usr.sbin/pciconf/pciconf.c

Modified: head/usr.sbin/pciconf/pciconf.c
==============================================================================
--- head/usr.sbin/pciconf/pciconf.c	Wed Oct 22 23:35:32 2014	(r273487)
+++ head/usr.sbin/pciconf/pciconf.c	Wed Oct 22 23:35:56 2014	(r273488)
@@ -662,16 +662,16 @@ getdevice(const char *name)
 	 * find the start of the unit.
 	 */
 	if (name[0] == '\0')
-		err(1, "Empty device name");
+		errx(1, "Empty device name");
 	cp = strchr(name, '\0');
 	assert(cp != NULL && cp != name);
 	cp--;
 	while (cp != name && isdigit(cp[-1]))
 		cp--;
-	if (cp == name)
+	if (cp == name || !isdigit(*cp))
 		errx(1, "Invalid device name");
 	if ((size_t)(cp - name) + 1 > sizeof(patterns[0].pd_name))
-		errx(1, "Device name i2s too long");
+		errx(1, "Device name is too long");
 	memcpy(patterns[0].pd_name, name, cp - name);
 	patterns[0].pd_unit = strtol(cp, &cp, 10);
 	assert(*cp == '\0');


More information about the svn-src-all mailing list