diff options
author | Olivier Blin <oblin@mandriva.com> | 2008-04-03 13:24:43 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.com> | 2008-04-03 13:24:43 +0000 |
commit | 40777f9e8a8d7387f52a262720f04c114e07f41b (patch) | |
tree | 99f51534c4199f9084e0c45d9c4d68db5f2ac819 /mdk-stage1 | |
parent | 7f545e155484fbe76ca5ba681053ed905f1d602b (diff) | |
download | drakx-backup-do-not-use-40777f9e8a8d7387f52a262720f04c114e07f41b.tar drakx-backup-do-not-use-40777f9e8a8d7387f52a262720f04c114e07f41b.tar.gz drakx-backup-do-not-use-40777f9e8a8d7387f52a262720f04c114e07f41b.tar.bz2 drakx-backup-do-not-use-40777f9e8a8d7387f52a262720f04c114e07f41b.tar.xz drakx-backup-do-not-use-40777f9e8a8d7387f52a262720f04c114e07f41b.zip |
fix segfault with empty device description (can happen for USB devices)
Diffstat (limited to 'mdk-stage1')
-rw-r--r-- | mdk-stage1/probing.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/mdk-stage1/probing.c b/mdk-stage1/probing.c index 8da6fada8..01d71e59b 100644 --- a/mdk-stage1/probing.c +++ b/mdk-stage1/probing.c @@ -94,6 +94,10 @@ static char * net_intf_too_early_name[50]; /* for modules providing more than on static int net_intf_too_early_number = 0; static int net_intf_too_early_ptr = 0; +const char * safe_descr(const char * text) { + return text ? text : "unknown"; +} + void prepare_intf_descr(const char * intf_descr) { intf_descr_for_discover = strdup(intf_descr); @@ -174,7 +178,7 @@ static void add_detected_device(unsigned short vendor, unsigned short device, un dev->subdevice = subdevice; strncpy(dev->module, module, sizeof(dev->module) - 1); dev->module[sizeof(dev->module) - 1] = '\0'; - strncpy(dev->description, name, sizeof(dev->description) - 1); + strncpy(dev->description, safe_descr(name), sizeof(dev->description) - 1); dev->description[sizeof(dev->description) - 1] = '\0'; log_message("detected device (%04x, %04x, %04x, %04x, %s, %s)", vendor, device, subvendor, subdevice, name, module); } @@ -261,7 +265,7 @@ static const char * get_alternate_module(const char * name) void discovered_device(enum driver_type type, const char * description, const char * driver) { - + description = safe_descr(description); enum insmod_return failed = INSMOD_FAILED; #ifndef DISABLE_MEDIAS @@ -304,7 +308,7 @@ void probe_pci_modules(enum driver_type type, char **pci_modules, unsigned int struct pciusb_entry *e = &entries.entries[i]; if (device_match_modules_list(e, pci_modules, pci_modules_len)) { log_message("PCI: device %04x %04x %04x %04x is \"%s\", driver is %s", - e->vendor, e->device, e->subvendor, e->subdevice, e->text, e->module); + e->vendor, e->device, e->subvendor, e->subdevice, safe_descr(e->text), e->module); discovered_device(type, e->text, e->module); } } @@ -385,7 +389,7 @@ void probe_that_type(enum driver_type type, enum media_bus bus __attribute__ ((u for (i = 0; i < entries.nb; i++) { struct pciusb_entry *e = &entries.entries[i]; if (device_match_modules_list(e, usb_modules, usb_modules_len)) { - log_message("USB: device %04x %04x is \"%s\" (%s)", e->vendor, e->device, e->text, e->module); + log_message("USB: device %04x %04x is \"%s\" (%s)", e->vendor, e->device, safe_descr(e->text), e->module); discovered_device(type, e->text, e->module); } } |