descriptor: Fix alignment for 32-bit words in parse_descriptor parse_descriptor was aligning 32-bit words to 2 bytes, instead of 4 bytes. This didn't cause any issues before, because the only time the 32-bit word code path is used is from a 3 byte offset (which incidentally aligns to 4 bytes). However, a 1 byte offset would incorrectly align to 2 bytes. Closes #734 Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
diff --git a/libusb/descriptor.c b/libusb/descriptor.c index 2097b84..be0aa83 100644 --- a/libusb/descriptor.c +++ b/libusb/descriptor.c
@@ -53,14 +53,14 @@ *dp++ = *sp++; break; case 'w': /* 16-bit word, convert from little endian to CPU */ - dp += ((uintptr_t)dp & 1); /* Align to word boundary */ + dp += ((uintptr_t)dp & 1); /* Align to word boundary */ *((uint16_t *)dp) = READ_LE16(sp); sp += 2; dp += 2; break; case 'd': /* 32-bit word, convert from little endian to CPU */ - dp += ((uintptr_t)dp & 1); /* Align to word boundary */ + dp = (uint8_t *)(((uintptr_t)dp + 3) & ~3); /* Align to word boundary */ *((uint32_t *)dp) = READ_LE32(sp); sp += 4;
diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 9f10b11..820c720 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h
@@ -1 +1 @@ -#define LIBUSB_NANO 11523 +#define LIBUSB_NANO 11524