diff -Nru cups-1.5.0/debian/changelog cups-1.5.0/debian/changelog --- cups-1.5.0/debian/changelog 2011-10-20 12:54:12.000000000 +0200 +++ cups-1.5.0/debian/changelog 2011-11-11 16:02:00.000000000 +0100 @@ -1,3 +1,18 @@ +cups (1.5.0-8ubuntu5) oneiric-proposed; urgency=low + + * debian/patches/usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch: + When reading out the device ID check also for too short lengths of the + device ID and also in this case try to chjange the byte order of the length + bytes and fail if the device ID lenght is still too short (LP: #887094). + * debian/patches/usb-backend-skip-set-configuration-set-interface.patch: + Avoid unneeded SET_CONFIGURATION and SET_INTERFACE requests after the + printer has already been configured. This often leads to subsequent jobs + coming out as garbage or not at all. + * debian/patches/usb-backend-reset-printer-before-printing.patch: Removed, + as we are trying the less invasive approach of CUPS STR #3965. + + -- Till Kamppeter Fri, 11 Nov 2011 16:01:43 +0100 + cups (1.5.0-8ubuntu4) oneiric-proposed; urgency=low * debian/patches/usb-backend-reset-printer-before-printing.patch: When diff -Nru cups-1.5.0/debian/patches/series cups-1.5.0/debian/patches/series --- cups-1.5.0/debian/patches/series 2011-10-20 12:49:09.000000000 +0200 +++ cups-1.5.0/debian/patches/series 2011-11-10 18:21:16.000000000 +0100 @@ -12,9 +12,10 @@ cups-avahi.patch colord-support.patch cups-driverd-recognize-cached-drv-generated-ppds.patch -usb-backend-reset-printer-before-printing.patch +usb-backend-skip-set-configuration-set-interface.patch # patches which should go upstream +usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch airprint-support.patch removecvstag.patch no-conffile-timestamp.patch diff -Nru cups-1.5.0/debian/patches/usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch cups-1.5.0/debian/patches/usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch --- cups-1.5.0/debian/patches/usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-1.5.0/debian/patches/usb-backend-gracefully-fail-on-more-cases-of-bad-device-id.patch 2011-11-10 18:30:06.000000000 +0100 @@ -0,0 +1,30 @@ +--- a/backend/usb-libusb.c ++++ b/backend/usb-libusb.c +@@ -430,15 +430,26 @@ + * Check to see if the length is larger than our buffer; first + * assume that the vendor incorrectly implemented the 1284 spec, + * and then limit the length to the size of our buffer... ++ * Consider a length < 14 as too short, as the minimum valid device ++ * ID ("MFG:x;MDL:y;") is 12 bytes long and so we have at least 14 ++ * bytes with the two length bytes... ++ * Especially the length in the memmove() call cannot get negative then, ++ * causing the backend to segfault. + */ + +- if (length > bufsize) ++ if ((length > bufsize) || (length < 14)) + length = (((unsigned)buffer[1] & 255) << 8) + + ((unsigned)buffer[0] & 255); + + if (length > bufsize) + length = bufsize; + ++ if (length < 14) ++ { ++ *buffer = '\0'; ++ return (-1); ++ } ++ + length -= 2; + + /* diff -Nru cups-1.5.0/debian/patches/usb-backend-skip-set-configuration-set-interface.patch cups-1.5.0/debian/patches/usb-backend-skip-set-configuration-set-interface.patch --- cups-1.5.0/debian/patches/usb-backend-skip-set-configuration-set-interface.patch 1970-01-01 01:00:00.000000000 +0100 +++ cups-1.5.0/debian/patches/usb-backend-skip-set-configuration-set-interface.patch 2011-11-10 00:40:07.000000000 +0100 @@ -0,0 +1,101 @@ +--- a/backend/usb-libusb.c ++++ b/backend/usb-libusb.c +@@ -631,6 +631,7 @@ + int verbose) /* I - Update connecting-to-device state? */ + { + int number; /* Configuration/interface/altset numbers */ ++ char current_bConfiguration; + + + /* +@@ -647,27 +648,40 @@ + if ((printer->handle = usb_open(printer->device)) == NULL) + return (-1); + +- /* +- * Then set the desired configuration... +- */ + + if (verbose) + fputs("STATE: +connecting-to-device\n", stderr); + ++ /* ++ * Set the desired configuration, but only if it needs changing. Some ++ * printers (e.g., Samsung) don't like usb_set_configuration. It will succeed, ++ * but the following print job is sometimes silently lost by the printer. ++ */ ++ if (usb_control_msg(printer->handle, ++ USB_TYPE_STANDARD | USB_ENDPOINT_IN | USB_RECIP_DEVICE, ++ 8, /* GET_CONFIGURATION */ ++ 0, 0, ¤t_bConfiguration, 1, 5000) != 1) ++ { ++ current_bConfiguration = 0; /* Failed. Assume not configured */ ++ } ++ + number = printer->device->config[printer->conf].bConfigurationValue; +- +- if (usb_set_configuration(printer->handle, number) < 0) ++ if (number != current_bConfiguration) + { +- /* +- * If the set fails, chances are that the printer only supports a +- * single configuration. Technically these printers don't conform to +- * the USB printer specification, but otherwise they'll work... +- */ + +- if (errno != EBUSY) +- fprintf(stderr, "DEBUG: Failed to set configuration %d for %04x:%04x\n", +- number, printer->device->descriptor.idVendor, +- printer->device->descriptor.idProduct); ++ if (usb_set_configuration(printer->handle, number) < 0) ++ { ++ /* ++ * If the set fails, chances are that the printer only supports a ++ * single configuration. Technically these printers don't conform to ++ * the USB printer specification, but otherwise they'll work... ++ */ ++ ++ if (errno != EBUSY) ++ fprintf(stderr, "DEBUG: Failed to set configuration %d for %04x:%04x\n", ++ number, printer->device->descriptor.idVendor, ++ printer->device->descriptor.idProduct); ++ } + } + + /* +@@ -700,20 +714,24 @@ + #endif /* 0 */ + + /* +- * Set alternate setting... ++ * Set alternate setting, but only if there is more than one option. ++ * Some printers (e.g., Samsung) don't like usb_set_altinterface. + */ +- +- number = printer->device->config[printer->conf].interface[printer->iface]. +- altsetting[printer->altset].bAlternateSetting; +- while (usb_set_altinterface(printer->handle, number) < 0) ++ if (printer->device->config[printer->conf].interface[printer->iface]. ++ num_altsetting > 1) + { +- if (errno != EBUSY) +- fprintf(stderr, +- "DEBUG: Failed to set alternate interface %d for %04x:%04x: %s\n", +- number, printer->device->descriptor.idVendor, +- printer->device->descriptor.idProduct, strerror(errno)); ++ number = printer->device->config[printer->conf].interface[printer->iface]. ++ altsetting[printer->altset].bAlternateSetting; ++ while (usb_set_altinterface(printer->handle, number) < 0) ++ { ++ if (errno != EBUSY) ++ fprintf(stderr, ++ "DEBUG: Failed to set alternate interface %d for %04x:%04x: %s\n", ++ number, printer->device->descriptor.idVendor, ++ printer->device->descriptor.idProduct, strerror(errno)); + +- goto error; ++ goto error; ++ } + } + + if (verbose)