fix use of uninitialized value in sin_cos

Resolves: RHEL-35392
This commit is contained in:
Lukáš Zaoral 2025-12-10 15:10:01 +01:00
parent 4b4992d231
commit 84403fe066
No known key found for this signature in database
GPG Key ID: 39157506DD67752D
2 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,38 @@
From 96295d88fc03795ce6ae03ee2daabf9639fd96cc Mon Sep 17 00:00:00 2001
From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Date: Wed, 30 Apr 2025 17:09:57 +0200
Subject: [PATCH] [sin_cos] fixed uninitialized value and added comments
(issue reported by Jerry James,
see https://sympa.inria.fr/sympa/arc/mpfr/2025-04/msg00039.html)
---
src/sin_cos.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/sin_cos.c b/src/sin_cos.c
index af0d87094..5279a4c29 100644
--- a/src/sin_cos.c
+++ b/src/sin_cos.c
@@ -331,6 +331,9 @@ sin_bs_aux (mpz_t Q0, mpz_t S0, mpz_t C0, mpz_srcptr p, mpfr_prec_t r,
mult[0] = r - pp_s + r0 - p_s;
/* we have x^3 < 1/2^mult[0] */
+ /* accu[k] is some bound for the k-th term, more precisely the k-th term
+ is bounded by 1/2^accu[k] */
+ accu[0] = 0;
for (i = 2, k = 0, prec_i_have = mult[0]; prec_i_have < prec; i += 2)
{
/* i is even here */
@@ -366,7 +369,8 @@ sin_bs_aux (mpz_t Q0, mpz_t S0, mpz_t C0, mpz_srcptr p, mpfr_prec_t r,
MPFR_MPZ_SIZEINBASE2(mult[k], Q[k]);
mult[k] += 2 * r - size_ptoj[1] - 1;
/* the absolute contribution of the next term is 1/2^accu[k] */
- accu[k] = (k == 0) ? mult[k] : mult[k] + accu[k-1];
+ MPFR_ASSERTD(k > 0);
+ accu[k] = mult[k] + accu[k-1];
prec_i_have = accu[k]; /* the current term is < 1/2^accu[k] */
j = (i + 2) / 2;
l = 1;
--
GitLab

View File

@ -1,7 +1,7 @@
Summary: C library for multiple-precision floating-point computations
Name: mpfr
Version: 4.1.0
Release: 7%{?dist}
Release: 8%{?dist}
URL: https://www.mpfr.org/
License: LGPLv3+
@ -21,6 +21,10 @@ Source0: https://www.mpfr.org/%{name}-%{version}/%{name}-%{version}.tar.xz
# - jyn-asympt-interm-zero.patch
Patch0: https://www.mpfr.org/%{name}-%{version}/allpatches
# fix use of uninitialized value in sin_cos (RHEL-35392)
# https://gitlab.inria.fr/mpfr/mpfr/-/commit/96295d88fc03795ce6ae03ee2daabf9639fd96cc
Patch: mpfr-sin_cos-uninit-var.patch
# This can be removed when F32 reaches EOL
Obsoletes: mpfr3 < 4.0.0
Provides: mpfr3 = %{version}-%{release}
@ -107,6 +111,9 @@ export LD_LIBRARY_PATH=%{buildroot}%{_libdir}
%{_infodir}/mpfr.info*
%changelog
* Wed Dec 10 2025 Lukáš Zaoral <lzaoral@redhat.com> - 4.1.0-8
- fix use of uninitialized value in sin_cos (RHEL-35392)
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 4.1.0-7
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688