commit:     f27391fc418baa5ce0f4b08e32235adb547d4e9f
Author:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
AuthorDate: Sat Oct  5 12:53:03 2024 +0000
Commit:     Michael Orlitzky <mjo <AT> gentoo <DOT> org>
CommitDate: Sat Oct  5 13:09:19 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f27391fc

sci-mathematics/gfan: new patch to fix out-of-bounds indexing

Fix the SageMath test suite by making sure gfan_mixedvolume doesn't
crash.

Closes: https://bugs.gentoo.org/897782
Signed-off-by: Michael Orlitzky <mjo <AT> gentoo.org>

 .../gfan/files/gfan-0.6.2-glibcxx-assertions.patch | 39 ++++++++++++++++++++++
 .../{gfan-0.6.2-r5.ebuild => gfan-0.6.2-r6.ebuild} |  1 +
 2 files changed, 40 insertions(+)

diff --git a/sci-mathematics/gfan/files/gfan-0.6.2-glibcxx-assertions.patch 
b/sci-mathematics/gfan/files/gfan-0.6.2-glibcxx-assertions.patch
new file mode 100644
index 000000000000..00c616d036fe
--- /dev/null
+++ b/sci-mathematics/gfan/files/gfan-0.6.2-glibcxx-assertions.patch
@@ -0,0 +1,39 @@
+From f0e9e24f1f20801bd49c78b30b951433f834a2c7 Mon Sep 17 00:00:00 2001
+From: Michael Orlitzky <[email protected]>
+Date: Sat, 5 Oct 2024 08:48:57 -0400
+Subject: [PATCH] src/gfanlib_tropicalhomotopy.h: avoid out-of-bounds vector
+ indexes
+
+Add a check to ensure that we don't try to access the -1st element of
+a vector. The code would be trying to subtract zero from the entry, so
+it was "harmless," but it does crash glibcxx when assertions are
+enabled (as they are on hardened Gentoo). This should allow the
+SageMath "mixed volume" tests to pass.
+---
+ src/gfanlib_tropicalhomotopy.h | 10 ++++++----
+ 1 file changed, 6 insertions(+), 4 deletions(-)
+
+diff --git a/src/gfanlib_tropicalhomotopy.h b/src/gfanlib_tropicalhomotopy.h
+index f3127ba..f6db26e 100644
+--- a/src/gfanlib_tropicalhomotopy.h
++++ b/src/gfanlib_tropicalhomotopy.h
+@@ -454,10 +454,12 @@ template<class mvtyp, class mvtypDouble, class 
mvtypDivisor>
+                       //chioices are "relative" so no update is needed.
+ 
+                       choices=parent.choices;
+-                      int numberToDrop=(subconfigurationIndex!=0) ? 
numberToDrop=k+1 : 0;
+-
+-                      choices[subconfigurationIndex-1].first-=numberToDrop;
+-                      choices[subconfigurationIndex-1].second-=numberToDrop;
++                      int numberToDrop = 0;
++                      if (subconfigurationIndex != 0) {
++                              numberToDrop=k+1;
++                              
choices[subconfigurationIndex-1].first-=numberToDrop;
++                              
choices[subconfigurationIndex-1].second-=numberToDrop;
++                      }
+ 
+                       denominator=parent.denominator;
+                       int offsetOld=0;
+-- 
+2.45.2
+

diff --git a/sci-mathematics/gfan/gfan-0.6.2-r5.ebuild 
b/sci-mathematics/gfan/gfan-0.6.2-r6.ebuild
similarity index 97%
rename from sci-mathematics/gfan/gfan-0.6.2-r5.ebuild
rename to sci-mathematics/gfan/gfan-0.6.2-r6.ebuild
index 47fbcc3b8e1d..c755b754b378 100644
--- a/sci-mathematics/gfan/gfan-0.6.2-r5.ebuild
+++ b/sci-mathematics/gfan/gfan-0.6.2-r6.ebuild
@@ -27,6 +27,7 @@ PATCHES=(
        "${FILESDIR}/${PN}-0.6.2-fix-0602ResultantFanProjection.patch"
        "${FILESDIR}/${PN}-0.6.2-fix-spelling-errors.patch"
        "${FILESDIR}/${PN}-0.6.2-find-name.patch"
+       "${FILESDIR}/${PN}-0.6.2-glibcxx-assertions.patch"
 )
 
 pkg_setup() {

Reply via email to