Module Name: src Committed By: fox Date: Sat Apr 4 21:26:17 UTC 2020
Modified Files: src/lib/libusbhid: parse.c Log Message: lib/libusbhid: Fix possible left shift changes signedness bit. This bug was reported by UBSan runs. lib/libusbhid/parse.c:246:20 Can result in left shift changes signedness bit as a side effect positive number can go negative, cast it to unsigned for the operation and silence the issue. Reviewed by: kamil@ To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/lib/libusbhid/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libusbhid/parse.c diff -u src/lib/libusbhid/parse.c:1.10 src/lib/libusbhid/parse.c:1.11 --- src/lib/libusbhid/parse.c:1.10 Sun Dec 10 20:38:14 2017 +++ src/lib/libusbhid/parse.c Sat Apr 4 21:26:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.10 2017/12/10 20:38:14 bouyer Exp $ */ +/* $NetBSD: parse.c,v 1.11 2020/04/04 21:26:16 fox Exp $ */ /* * Copyright (c) 1999, 2001 Lennart Augustsson <augus...@netbsd.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__RCSID("$NetBSD: parse.c,v 1.10 2017/12/10 20:38:14 bouyer Exp $"); +__RCSID("$NetBSD: parse.c,v 1.11 2020/04/04 21:26:16 fox Exp $"); #include <assert.h> #include <stdlib.h> @@ -243,7 +243,7 @@ hid_get_item_raw(hid_data_t s, hid_item_ dval = *data++; dval |= *data++ << 8; dval |= *data++ << 16; - dval |= *data++ << 24; + dval |= ((uint32_t)*data++) << 24; break; default: return (-1);