]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
string: Fix UB on gneric stpcpy
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Apr 2025 17:28:35 +0000 (14:28 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 May 2025 17:21:21 +0000 (14:21 -0300)
Building with ubsan it trigger:

UBSAN: Undefined behaviour in ../string/stpcpy.c:91:12 shift exponent 56 is too large for 32-bit type 'int'

Use an unsigned constant literal for MERGE, since op_t is defined
as unsigned.

string/stpcpy.c

index 214802266c7d1fae038ea6221beab4a73ecf4405..0fe1b99192de66ae932b217297077ce89bf580c9 100644 (file)
@@ -88,7 +88,7 @@ stpcpy_unaligned_loop (op_t *restrict dst, const op_t *restrict src,
        }
 
       /* Align the final partial of P2.  */
-      w2 = MERGE (w2b, sh_1, 0, sh_2);
+      w2 = MERGE (w2b, sh_1, 0UL, sh_2);
     }
 
 out: