From 3534b2c7c70776c7d4ed98b435949832981ac3aa Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 28 Jan 2020 12:30:23 +0100 Subject: [PATCH] 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 --- lib/randutils.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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); -- 2.47.2