From: Karel Zak Date: Tue, 28 Jan 2020 11:30:23 +0000 (+0100) Subject: lib/randutils: use explicit data types for bit ops X-Git-Tag: v2.36-rc1~244 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3534b2c7c70776c7d4ed98b435949832981ac3aa;p=thirdparty%2Futil-linux.git lib/randutils: use explicit data types for bit ops ASAN is pretty unhappy with getpid() << 16, it seems better to save into unsigned int and than do the bit-op. Addresses: https://github.com/karelzak/util-linux/issues/942 Signed-off-by: Karel Zak --- diff --git a/lib/randutils.c b/lib/randutils.c index e5deb74f18..01a3d09036 100644 --- a/lib/randutils.c +++ b/lib/randutils.c @@ -60,9 +60,12 @@ static void crank_random(void) { int i; struct timeval tv; + unsigned int n_pid, n_uid; gettimeofday(&tv, NULL); - srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec); + n_pid = getpid(); + n_uid = getuid(); + srand((n_pid << 16) ^ n_uid ^ tv.tv_sec ^ tv.tv_usec); #ifdef DO_JRAND_MIX ul_jrand_seed[0] = getpid() ^ (tv.tv_sec & 0xFFFF);