From: Adhemerval Zanella Date: Fri, 18 Apr 2025 12:40:51 +0000 (-0300) Subject: locale: Fix UB in elem_hash X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e44f1e0b6662e6c805945dcfcd3acbff5f0ba69;p=thirdparty%2Fglibc.git locale: Fix UB in elem_hash The ubsan triggers: UBSAN: Undefined behaviour in ./elem-hash.h:27:14 left shift of 360447856 by 3 cannot be represented in type 'int' Using unsigned shift here zero fill like signed. --- diff --git a/locale/elem-hash.h b/locale/elem-hash.h index 5d34ec43f3..8052b0fe6d 100644 --- a/locale/elem-hash.h +++ b/locale/elem-hash.h @@ -24,7 +24,7 @@ elem_hash (const char *str, int32_t n) while (n-- > 0) { - result <<= 3; + result = (uint32_t)result << 3; result += *str++; }