Bug 194506 - [PATCH] "pciconf -a" asserts with unemerated device names
Summary: [PATCH] "pciconf -a" asserts with unemerated device names
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-10-21 06:38 UTC by Anthony Cornehl
Modified: 2014-12-03 19:45 UTC (History)
2 users (show)

See Also:
bugmeister: mfc-stable10?
bugmeister: mfc-stable9?
bugmeister: mfc-stable8?


Attachments
patch (408 bytes, text/plain)
2014-10-21 06:38 UTC, Anthony Cornehl
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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