Memcpy the data from wherever it is in memory to a 'struct input_event' that is living on the stack with proper alignment. Fixes the following complaints from Clang's undefined sanitizer:
../src/wcmUSB.c:966:13: runtime error: member access within misaligned address 0x62e00008e494 for type 'const struct input_event', which requires 8 byte alignment 0x62e00008e494: note: pointer points here 78 00 00 00 db 5b 3e 55 00 00 00 00 d9 d7 03 00 00 00 00 00 03 00 00 00 e9 09 00 00 db 5b 3e 55 ^ SUMMARY: AddressSanitizer: undefined-behavior ../src/wcmUSB.c:966 ../src/wcmUSB.c:966:38: runtime error: member access within misaligned address 0x62e00008e494 for type 'const struct input_event', which requires 8 byte alignment 0x62e00008e494: note: pointer points here 78 00 00 00 db 5b 3e 55 00 00 00 00 d9 d7 03 00 00 00 00 00 03 00 00 00 e9 09 00 00 db 5b 3e 55 ^ SUMMARY: AddressSanitizer: undefined-behavior ../src/wcmUSB.c:966 ../src/wcmUSB.c:983:14: runtime error: member access within misaligned address 0x62e00008e4f4 for type 'const struct input_event', which requires 8 byte alignment 0x62e00008e4f4: note: pointer points here 01 00 00 00 db 5b 3e 55 00 00 00 00 d9 d7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ SUMMARY: AddressSanitizer: undefined-behavior ../src/wcmUSB.c:983 ../src/wcmUSB.c:1000:21: runtime error: member access within misaligned address 0x62e00008e4f4 for type 'const struct input_event', which requires 8 byte alignment 0x62e00008e4f4: note: pointer points here 01 00 00 00 db 5b 3e 55 00 00 00 00 d9 d7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ SUMMARY: AddressSanitizer: undefined-behavior ../src/wcmUSB.c:1000 ../src/wcmUSB.c:1000:48: runtime error: member access within misaligned address 0x62e00008e4f4 for type 'const struct input_event', which requires 8 byte alignment 0x62e00008e4f4: note: pointer points here 01 00 00 00 db 5b 3e 55 00 00 00 00 d9 d7 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ^ SUMMARY: AddressSanitizer: undefined-behavior ../src/wcmUSB.c:1000 Signed-off-by: Jason Gerecke <jason.gere...@wacom.com> --- src/wcmUSB.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/wcmUSB.c b/src/wcmUSB.c index c15cd4a..5ceba95 100644 --- a/src/wcmUSB.c +++ b/src/wcmUSB.c @@ -815,11 +815,13 @@ static int usbParse(InputInfoPtr pInfo, const unsigned char* data, int len) { WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; WacomCommonPtr common = priv->common; + struct input_event event; if (len < sizeof(struct input_event)) return 0; - usbParseEvent(pInfo, (const struct input_event*)data); + memcpy(&event, data, sizeof(event)); + usbParseEvent(pInfo, &event); return common->wcmPktLength; } -- 2.3.5 ------------------------------------------------------------------------------ One dashboard for servers and applications across Physical-Virtual-Cloud Widest out-of-the-box monitoring support with 50+ applications Performance metrics, stats and reports that give you Actionable Insights Deep dive visibility with transaction tracing using APM Insight. http://ad.doubleclick.net/ddm/clk/290420510;117567292;y _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel