Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/usb Convert unsigned char to wider type before left ...
details: https://anonhg.NetBSD.org/src/rev/afafa6c0406a
branches: trunk
changeset: 343145:afafa6c0406a
user: riastradh <riastradh%NetBSD.org@localhost>
date: Sat Jan 23 17:02:25 2016 +0000
description:
Convert unsigned char to wider type before left shift.
Avoids undefined behaviour if shifted quantity overflows int.
CID 980971
diffstat:
sys/dev/usb/hid.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diffs (27 lines):
diff -r b69441836354 -r afafa6c0406a sys/dev/usb/hid.c
--- a/sys/dev/usb/hid.c Sat Jan 23 16:39:31 2016 +0000
+++ b/sys/dev/usb/hid.c Sat Jan 23 17:02:25 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hid.c,v 1.42 2016/01/10 17:44:48 jakllsch Exp $ */
+/* $NetBSD: hid.c,v 1.43 2016/01/23 17:02:25 riastradh Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.42 2016/01/10 17:44:48 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.43 2016/01/23 17:02:25 riastradh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -461,7 +461,7 @@
num = (hpos + hsize + 7) / 8 - off;
for (i = 0; i < num; i++)
- data |= buf[off + i] << (i * 8);
+ data |= (unsigned long)buf[off + i] << (i * 8);
data >>= hpos % 8;
if (hsize < sizeof(data) * NBBY)
Home |
Main Index |
Thread Index |
Old Index