]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
math: Fix UB on sinhf (BZ 32921)
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 25 Apr 2025 20:54:25 +0000 (17:54 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 29 Apr 2025 18:20:04 +0000 (15:20 -0300)
The left shift overflows for 'int', use uint64_t instead.  It syncs
with CORE-MATH commit bbfabd99.

Checked on aarch64-linux-gnu, x86_64-linux-gnu, and i686-linux-gnu.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
sysdeps/ieee754/flt-32/e_sinhf.c

index 754b84abe0b0a422424405048b0aa7c72fee8426..6c8c1db404f165ccce8ad03cc1bb20b6fd1aec71 100644 (file)
@@ -3,7 +3,7 @@
 Copyright (c) 2022-2024 Alexei Sibidanov.
 
 The original version of this file was copied from the CORE-MATH
-project (file src/binary32/sinh/sinhf.c, revision 572ecec).
+project (file src/binary32/sinh/sinhf.c, revision bbfabd99).
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
@@ -83,8 +83,8 @@ __ieee754_sinhf (float x)
   double h2 = h * h;
   int64_t jp = asuint64 (ia + 0x1.8p52);
   int64_t jm = -jp;
-  double sp = asdouble (TB[jp & 31] + ((jp >> 5) << 52));
-  double sm = asdouble (TB[jm & 31] + ((jm >> 5) << 52));
+  double sp = asdouble (TB[jp & 31] + ((uint64_t)(jp >> 5) << 52));
+  double sm = asdouble (TB[jm & 31] + ((uint64_t)(jm >> 5) << 52));
   double te = C[0] + h2 * C[2];
   double to = (C[1] + h2 * C[3]);
   double rp = sp * (te + h * to);