Module Name: src Committed By: martin Date: Sun Sep 18 13:34:07 UTC 2022
Modified Files: src/sys/dev/usb [netbsd-9]: usb.h Log Message: Pull up following revision(s) (requested by msaitoh in ticket #1529): sys/dev/usb/usb.h: revision 1.121 Cast to uint32_t to avoid undefined behavior in UGETDW(). Found by kUBSan. To generate a diff of this commit: cvs rdiff -u -r1.116.6.1 -r1.116.6.2 src/sys/dev/usb/usb.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/usb.h diff -u src/sys/dev/usb/usb.h:1.116.6.1 src/sys/dev/usb/usb.h:1.116.6.2 --- src/sys/dev/usb/usb.h:1.116.6.1 Sun Sep 1 13:00:37 2019 +++ src/sys/dev/usb/usb.h Sun Sep 18 13:34:06 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: usb.h,v 1.116.6.1 2019/09/01 13:00:37 martin Exp $ */ +/* $NetBSD: usb.h,v 1.116.6.2 2022/09/18 13:34:06 martin Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -78,7 +78,8 @@ typedef uint8_t uDWord[4]; #define UGETW(w) ((w)[0] | ((w)[1] << 8)) #define USETW(w,v) ((w)[0] = (uint8_t)(v), (w)[1] = (uint8_t)((v) >> 8)) #define USETWD(val) { (uint8_t)(val), (uint8_t)((val) >> 8) } -#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24)) +#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | \ + ((uint32_t)(w)[3] << 24)) #define USETDW(w,v) ((w)[0] = (uint8_t)(v), \ (w)[1] = (uint8_t)((v) >> 8), \ (w)[2] = (uint8_t)((v) >> 16), \