Comment 3 for bug 1699161

Revision history for this message
Rafael David Tinoco (rafaeldtinoco) wrote : Re: lshw crashes with SEGV

According to this core:

(gdb) bt
#0 _IO_feof (fp=fp@entry=0x0) at feof.c:35
#1 0x000000000045dd88 in scan_usb (n=...) at usb.cc:383
#2 0x0000000000418279 in scan_system (system=...) at main.cc:113
#3 0x0000000000404571 in main (argc=1, argv=0x7ffc719cb4d8) at lshw.cc:238

The crash has happened when scanning from USB:

usbdevices = fopen(SYSKERNELDEBUGUSBDEVICES, "r");
if(!usbdevices)
__usbdevices = fopen(PROCBUSUSBDEVICES, "r");

while(!feof(usbdevices))
{

It is likely that it couldn't open one of these files:

#define PROCBUSUSBDEVICES "/proc/bus/usb/devices"
#define SYSKERNELDEBUGUSBDEVICES "/sys/kernel/debug/usb/devices"

Because of permission, since there was already check if the files existed before the code bellow:

if (!exists(SYSKERNELDEBUGUSBDEVICES) && !exists(PROCBUSUSBDEVICES))
__return false;

Code Problem (so far): code doesn't check if the second opening was successful before moving on. If SYSKERNELDEBUGUSBDEVICES exists but can't be opened AND PROCBUSUSBDEVICE doesn't exist, it will still try to open it not checking if it could.