diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-05-13 16:46:08 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2013-05-13 16:46:08 +0000 |
commit | 2a241c9efcf4c422c64307e1034e156965e770d2 (patch) | |
tree | e154e406ceb46cc8ec2711eb8da580a33faa5a6d | |
parent | 90c6ec2104df6ee54bfd4f5ef017a5dac93172e1 (diff) |
<rdar://problem/13875729> cups.org: libusb-based backend can crash if USB is disabled in BIOS
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10977 a1ca3aef-8c08-0410-bb20-df032aa958be
-rw-r--r-- | CHANGES-1.6.txt | 2 | ||||
-rw-r--r-- | backend/usb-libusb.c | 15 |
2 files changed, 14 insertions, 3 deletions
diff --git a/CHANGES-1.6.txt b/CHANGES-1.6.txt index 26151353d..22d871068 100644 --- a/CHANGES-1.6.txt +++ b/CHANGES-1.6.txt @@ -5,6 +5,8 @@ CHANGES IN CUPS V1.6.3 - The configure script now prefers Clang over GCC. - Fixed a compile problem on AIX (STR #4307) + - The USB backend could crash on libusb-based systems if USB was + disabled in the BIOS (<rdar://problem/13875729>) - Fixed a rounding error in the PWG media size mapping code (<rdar://problem/13493241>) - Fixed several ipptool test files that used old STATUS names. diff --git a/backend/usb-libusb.c b/backend/usb-libusb.c index bbce39a62..dc32bd082 100644 --- a/backend/usb-libusb.c +++ b/backend/usb-libusb.c @@ -899,7 +899,8 @@ find_device(usb_cb_t cb, /* I - Callback function */ /* Pointer to current alternate setting */ const struct libusb_endpoint_descriptor *endpptr = NULL; /* Pointer to current endpoint */ - ssize_t numdevs, /* number of connected devices */ + ssize_t err = 0, /* Error code */ + numdevs, /* number of connected devices */ i = 0; uint8_t conf, /* Current configuration */ iface, /* Current interface */ @@ -918,7 +919,14 @@ find_device(usb_cb_t cb, /* I - Callback function */ * Initialize libusb... */ - libusb_init(NULL); + err = libusb_init(NULL); + if (err) + { + fprintf(stderr, "DEBUG: Unable to initialize USB access via libusb, " + "libusb error %i\n", err); + return (NULL); + } + numdevs = libusb_get_device_list(NULL, &list); fprintf(stderr, "DEBUG: libusb_get_device_list=%d\n", (int)numdevs); @@ -1088,7 +1096,8 @@ find_device(usb_cb_t cb, /* I - Callback function */ * Clean up .... */ - libusb_free_device_list(list, 1); + if (numdevs >= 0) + libusb_free_device_list(list, 1); libusb_exit(NULL); return (NULL); |