From: Adhemerval Zanella Date: Tue, 22 Apr 2025 17:30:06 +0000 (-0300) Subject: string: Fix UB on generic strcmp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=278994710b977b423c172f7626a64026d447d8dd;p=thirdparty%2Fglibc.git string: Fix UB on generic strcmp Building with ubsan it trigger: UBSAN: Undefined behaviour in ../string/strcmp.c:92:12 shift exponent 32 is too large for 32-bit type 'int' Use an unsigned constant literal for MERGE, since op_t is defined as unsigned. --- diff --git a/string/strcmp.c b/string/strcmp.c index f79dd926d3..3a325115b2 100644 --- a/string/strcmp.c +++ b/string/strcmp.c @@ -89,7 +89,7 @@ strcmp_unaligned_loop (const op_t *x1, const op_t *x2, op_t w1, uintptr_t ofs) /* Load the final word of P1 and align the final partial of P2. */ w1 = *x1++; - w2 = MERGE (w2b, sh_1, 0, sh_2); + w2 = MERGE (w2b, sh_1, 0UL, sh_2); } return final_cmp (w1, w2);