|
|
f26964f |
diff -up cups-1.4rc1/backend/ieee1284.c.device-id cups-1.4rc1/backend/ieee1284.c
|
|
|
f26964f |
--- cups-1.4rc1/backend/ieee1284.c.device-id 2009-07-18 18:25:38.355769382 +0100
|
|
|
f26964f |
+++ cups-1.4rc1/backend/ieee1284.c 2009-07-18 18:25:43.844894365 +0100
|
|
|
f26964f |
@@ -196,12 +196,19 @@ backendGetDeviceID(
|
|
|
f26964f |
* and then limit the length to the size of our buffer...
|
|
|
f26964f |
*/
|
|
|
f26964f |
|
|
|
f26964f |
- if (length > (device_id_size - 2))
|
|
|
f26964f |
+ if (length > device_id_size)
|
|
|
f26964f |
length = (((unsigned)device_id[1] & 255) << 8) +
|
|
|
f26964f |
((unsigned)device_id[0] & 255);
|
|
|
f26964f |
|
|
|
f26964f |
- if (length > (device_id_size - 2))
|
|
|
f26964f |
- length = device_id_size - 2;
|
|
|
f26964f |
+ if (length > device_id_size)
|
|
|
f26964f |
+ length = device_id_size;
|
|
|
f26964f |
+
|
|
|
f26964f |
+ /*
|
|
|
f26964f |
+ * The length field counts the number of bytes in the string
|
|
|
f26964f |
+ * including the length field itself (2 bytes).
|
|
|
f26964f |
+ */
|
|
|
f26964f |
+
|
|
|
f26964f |
+ length -= 2;
|
|
|
f26964f |
|
|
|
f26964f |
/*
|
|
|
f26964f |
* Copy the device ID text to the beginning of the buffer and
|
|
|
f26964f |
diff -up cups-1.4rc1/backend/usb-libusb.c.device-id cups-1.4rc1/backend/usb-libusb.c
|
|
|
f26964f |
--- cups-1.4rc1/backend/usb-libusb.c.device-id 2009-01-14 19:46:43.000000000 +0000
|
|
|
f26964f |
+++ cups-1.4rc1/backend/usb-libusb.c 2009-07-18 18:25:43.845895048 +0100
|
|
|
f26964f |
@@ -418,12 +418,14 @@ get_device_id(usb_printer_t *printer, /*
|
|
|
f26964f |
* and then limit the length to the size of our buffer...
|
|
|
f26964f |
*/
|
|
|
f26964f |
|
|
|
f26964f |
- if (length > (bufsize - 2))
|
|
|
f26964f |
+ if (length > bufsize)
|
|
|
f26964f |
length = (((unsigned)buffer[1] & 255) << 8) +
|
|
|
f26964f |
((unsigned)buffer[0] & 255);
|
|
|
f26964f |
|
|
|
f26964f |
- if (length > (bufsize - 2))
|
|
|
f26964f |
- length = bufsize - 2;
|
|
|
f26964f |
+ if (length > bufsize)
|
|
|
f26964f |
+ length = bufsize;
|
|
|
f26964f |
+
|
|
|
f26964f |
+ length -= 2;
|
|
|
f26964f |
|
|
|
f26964f |
/*
|
|
|
f26964f |
* Copy the device ID text to the beginning of the buffer and
|