From: Adhemerval Zanella Date: Fri, 25 Apr 2025 20:54:24 +0000 (-0300) Subject: math: Fix UB on logf (BZ 32920) X-Git-Tag: glibc-2.42~279 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=de0c4adf94a379873c0167f792519e91df28c3ed;p=thirdparty%2Fglibc.git math: Fix UB on logf (BZ 32920) The left shift overflows for 'int', use a literal instead. It syncs with OPTIMIZED-ROUTINES commit 0f87f607b976820ef41fe64d004fe67dc7af8236. Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Carlos O'Donell --- diff --git a/sysdeps/ieee754/flt-32/e_logf.c b/sysdeps/ieee754/flt-32/e_logf.c index 6a595cf7f0..207151c76a 100644 --- a/sysdeps/ieee754/flt-32/e_logf.c +++ b/sysdeps/ieee754/flt-32/e_logf.c @@ -70,7 +70,7 @@ __logf (float x) tmp = ix - OFF; i = (tmp >> (23 - LOGF_TABLE_BITS)) % N; k = (int32_t) tmp >> 23; /* arithmetic shift */ - iz = ix - (tmp & 0x1ff << 23); + iz = ix - (tmp & 0xff800000); invc = T[i].invc; logc = T[i].logc; z = (double_t) asfloat (iz);