From: Adhemerval Zanella Date: Fri, 25 Apr 2025 20:54:22 +0000 (-0300) Subject: math: Fix UB on atanhf (BZ 32918) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=92f7b6061d867c5e5f26e84c44a3ec2887bf6c81;p=thirdparty%2Fglibc.git math: Fix UB on atanhf (BZ 32918) The left shift overflows for 'int', use unsigned instead. It syncs with CORE-MATH commit 4d6192d2. 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_atanhf.c b/sysdeps/ieee754/flt-32/e_atanhf.c index 5138408324..eeb1aae6a1 100644 --- a/sysdeps/ieee754/flt-32/e_atanhf.c +++ b/sysdeps/ieee754/flt-32/e_atanhf.c @@ -3,7 +3,7 @@ Copyright (c) 2023-2024 Alexei Sibidanov. The original version of this file was copied from the CORE-MATH -project (file src/binary32/acosh/acoshf.c, revision bc385c2). +project (file src/binary32/acosh/acoshf.c, revision 4d6192d2). Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -135,7 +135,7 @@ __ieee754_atanhf (float x) } double sgn = s[ux >> 31]; unsigned int e = ax >> 24; - unsigned int md = ((ux << 8) | 1 << 31) >> (126 - e); + unsigned int md = ((ux << 8) | 1U << 31) >> (126 - e); unsigned int mn = -md; int nz = __builtin_clz (mn) + 1; mn <<= nz;