From: Adhemerval Zanella Date: Tue, 22 Apr 2025 17:35:39 +0000 (-0300) Subject: string: Fix UB on gneric strncmp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=766ed3827547d5930c95b80c38a056fea358ef6b;p=thirdparty%2Fglibc.git string: Fix UB on gneric strncmp Building with ubsan it triggers: UBSAN: Undefined behaviour in ../string/strncmp.c:103: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/strncmp.c b/string/strncmp.c index 79a21c12a3..746d5acc25 100644 --- a/string/strncmp.c +++ b/string/strncmp.c @@ -100,7 +100,7 @@ strncmp_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, n);