@@ -1,20 +1,37 @@
1−{ stdenv, fetchurl
2−, gmp, readline, libX11, tex, perl
1+{ stdenv
2+, fetchurl
3+, fetchpatch
4+, gmp
5+, readline
6+, libX11
7+, tex
8+, perl
39, withThread ? true, libpthreadstubs
410}:
511
612assert withThread -> libpthreadstubs != null;
713
814stdenv.mkDerivation rec {
9−
10− name = "pari-${version}";
15+ pname = "pari";
1116 version = "2.11.1";
1217
1318 src = fetchurl {
14− url = "https://pari.math.u-bordeaux.fr/pub/pari/unix/${name}.tar.gz";
19+ url = "https://pari.math.u-bordeaux.fr/pub/pari/unix/${pname}-${version}.tar.gz";
1520 sha256 = "1jfax92jpydjd02fwl30r6b8kfzqqd6sm4yx94gidyz9lqjb7a94";
1621 };
1722
23+ patches = [
24+ # Fix a off-by-one bug that can potentially lead to segfaults (accepted upstream)
25+ # https://pari.math.u-bordeaux.fr/cgi-bin/bugreport.cgi?bug=2117
26+ # https://trac.sagemath.org/ticket/27335
27+ (fetchpatch {
28+ name = "fix-off-by-one-error.patch";
29+ # only relevant parts of https://pari.math.u-bordeaux.fr/cgi-bin/gitweb.cgi?p=pari.git;a=patch;h=aa1ee6e0898d177e6bcf49237d82c804bc410985
30+ url = "https://git.sagemath.org/sage.git/plain/build/pkgs/pari/patches/red_montgomery.patch?id=bbea55c96e1f05302b3c7f593cf64492497047c5";
31+ sha256 = "0vqkmhgv9splsdswp6zjnkj50z76rc1m6k9iy3cf9dxwqw3h3nr6";
32+ })
33+ ];
34+
1835 buildInputs = [
1936 gmp
2037 readline
@@ -70,7 +87,7 @@ stdenv.mkDerivation rec {
7087 homepage = http://pari.math.u-bordeaux.fr;
7188 downloadPage = http://pari.math.u-bordeaux.fr/download.html;
7289 license = licenses.gpl2Plus;
73− maintainers = with maintainers; [ ertes raskin AndersonTorres ];
90+ maintainers = with maintainers; [ ertes raskin AndersonTorres timokau ];
7491 platforms = platforms.linux ++ platforms.darwin;
7592 updateWalker = true;
7693 };