]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
<rdar://problem/13875729> cups.org: libusb-based backend can crash if USB is disabled...
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 13 May 2013 16:46:08 +0000 (16:46 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 13 May 2013 16:46:08 +0000 (16:46 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@10977 a1ca3aef-8c08-0410-bb20-df032aa958be

CHANGES-1.6.txt
backend/usb-libusb.c

index 26151353d4710084545f593d4dfa1a2e185127f1..22d871068673f31b1547ec3a6b7a9a26eb4e7609 100644 (file)
@@ -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.
index bbce39a62e59f57a2d1446884e82a5346e70c619..dc32bd082ba6baf4a36cf6d63608d87df7dcb987 100644 (file)
@@ -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);