From: Jouni Malinen Date: Tue, 7 Jul 2015 12:54:31 +0000 (+0300) Subject: Avoid ubsan warning on 0x80<<24 not fitting in int in WPA_GET_BE32/LE32 X-Git-Tag: hostap_2_5~461 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=476a634d601821c05b4eb7a84f4cf3c65740212d;p=thirdparty%2Fhostap.git Avoid ubsan warning on 0x80<<24 not fitting in int in WPA_GET_BE32/LE32 Use a typecast to make this shift unsigned so that the MSB fits within the range of allowed values. Signed-off-by: Jouni Malinen --- diff --git a/src/utils/common.h b/src/utils/common.h index b14035513..651ce2eb5 100644 --- a/src/utils/common.h +++ b/src/utils/common.h @@ -262,7 +262,7 @@ static inline void WPA_PUT_BE24(u8 *a, u32 val) static inline u32 WPA_GET_BE32(const u8 *a) { - return (a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; + return ((u32) a[0] << 24) | (a[1] << 16) | (a[2] << 8) | a[3]; } static inline void WPA_PUT_BE32(u8 *a, u32 val) @@ -275,7 +275,7 @@ static inline void WPA_PUT_BE32(u8 *a, u32 val) static inline u32 WPA_GET_LE32(const u8 *a) { - return (a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]; + return ((u32) a[3] << 24) | (a[2] << 16) | (a[1] << 8) | a[0]; } static inline void WPA_PUT_LE32(u8 *a, u32 val)