]> git.ipfire.org Git - thirdparty/glibc.git/commit
stdlib: Fix UB on erand48/jrand48
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 22 Apr 2025 17:06:33 +0000 (14:06 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Wed, 7 May 2025 17:21:21 +0000 (14:21 -0300)
commitc378eb43889f3b9555b34bda8edf1519d79e1d97
tree58e5b51babb6b2f6a08dc05d3f1ea153f148e69b
parentea81e7d8c61b6dc8abe02309708aa895555be60c
stdlib: Fix UB on erand48/jrand48

With glibc built with ubsan it triggers:

UBSAN: Undefined behaviour in jrand48_r.c:29:34 left shift of 41612 by 16 cannot be represented in type 'int'
UBSAN: Undefined behaviour in erand48_r.c:39:45 left shift of 3972 by 20 cannot be represented in type 'int'

Fix by casting to uint32_t for the shift operation.
stdlib/erand48_r.c
stdlib/jrand48_r.c