pciconf(8): Replace an assert with errx

The condition can be hit with simple user input, so it isn't an invariant.
Just error out.

PR:		217003
Reported by:	Vladislav V. Prodan <admin at support.od.ua>
Sponsored by:	Dell EMC Isilon
This commit is contained in:
Conrad Meyer 2017-02-11 18:04:43 +00:00
parent 5ede40dcf2
commit ae9dddfc09

View File

@ -879,7 +879,8 @@ getdevice(const char *name)
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');
if (*cp != '\0')
errx(1, "Invalid device name");
patterns[0].flags = PCI_GETCONF_MATCH_NAME | PCI_GETCONF_MATCH_UNIT;
pc.num_patterns = 1;
pc.pat_buf_len = sizeof(patterns);