summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Orlitzky <mjo@gentoo.org>2024-10-05 08:53:03 -0400
committerMichael Orlitzky <mjo@gentoo.org>2024-10-05 09:09:19 -0400
commitf27391fc418baa5ce0f4b08e32235adb547d4e9f (patch)
treea447b27b403bfac946ada3467b3ad3ba229fd475 /sci-mathematics
parentsys-auth/oath-toolkit: Stabilize 2.6.12 ppc64, #940902 (diff)
downloadgentoo-f27391fc418baa5ce0f4b08e32235adb547d4e9f.tar.gz
gentoo-f27391fc418baa5ce0f4b08e32235adb547d4e9f.tar.bz2
gentoo-f27391fc418baa5ce0f4b08e32235adb547d4e9f.zip
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@gentoo.org>
Diffstat (limited to 'sci-mathematics')
-rw-r--r--sci-mathematics/gfan/files/gfan-0.6.2-glibcxx-assertions.patch39
-rw-r--r--sci-mathematics/gfan/gfan-0.6.2-r6.ebuild (renamed from sci-mathematics/gfan/gfan-0.6.2-r5.ebuild)1
2 files changed, 40 insertions, 0 deletions
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 <michael@orlitzky.com>
+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
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() {