Bug 194506

Summary: [PATCH] "pciconf -a" asserts with unemerated device names
Product: Base System Reporter: Anthony Cornehl <accornehl>
Component: binAssignee: Mark Johnston <markj>
Status: Closed FIXED    
Severity: Affects Only Me CC: benno, markj
Priority: --- Flags: bugmeister: mfc-stable10?
bugmeister: mfc-stable9?
bugmeister: mfc-stable8?
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
patch none

Description Anthony Cornehl 2014-10-21 06:38:39 UTC
Created attachment 148530 [details]
patch

I noticed that passing an unenumerated device name to pciconf caused an assert, for what otherwise looks like valid input.

# /usr/sbin/pciconf -a bge
Assertion failed: (*cp == '\0'), function getdevice, file /usr/home/acornehl/freebsd/usr.sbin/pciconf/pciconf.c, line 677.
Abort trap (core dumped)

# /usr/sbin/pciconf -a bge0
bge0: attached

The function, getdevice(), expects that the device name is enumerated before processing the string, and hits the assert when it isn't. I've added a small patch checking before walking the string to check if it is enumerated or not and returning an error instead of an assert.

# ./pciconf -a bge
pciconf: Device not found

# ./pciconf -a bge0
bge0: attached

# ./pciconf -a foobar
pciconf: Device not found

# ./pciconf -a foobar0
pciconf: Device not found
Comment 1 commit-hook freebsd_committer freebsd_triage 2014-10-22 23:36:56 UTC
A commit references this bug:

Author: markj
Date: Wed Oct 22 23:35:57 UTC 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@gmail.com>
  Sponsored by:	EMC / Isilon Storage Division

Changes:
  head/usr.sbin/pciconf/pciconf.c
Comment 2 commit-hook freebsd_committer freebsd_triage 2014-12-03 19:44:37 UTC
A commit references this bug:

Author: markj
Date: Wed Dec  3 19:44:23 UTC 2014
New revision: 275465
URL: https://svnweb.freebsd.org/changeset/base/275465

Log:
  MFC r273488:
  Fix some bugs in the error handling of getdevice().

  PR:	194506

Changes:
_U  stable/10/
  stable/10/usr.sbin/pciconf/pciconf.c
Comment 3 commit-hook freebsd_committer freebsd_triage 2014-12-03 19:44:39 UTC
A commit references this bug:

Author: markj
Date: Wed Dec  3 19:44:24 UTC 2014
New revision: 275466
URL: https://svnweb.freebsd.org/changeset/base/275466

Log:
  MFC r273488:
  Fix some bugs in the error handling of getdevice().

  PR:	194506

Changes:
_U  stable/9/usr.sbin/pciconf/
  stable/9/usr.sbin/pciconf/pciconf.c