From 2d18d6d55a42beca2605f10315091c8945f9b521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= Date: Thu, 2 Jan 2025 22:22:06 -0300 Subject: [PATCH] m4ri: update to 20250128. --- common/shlibs | 2 +- .../m4ri/patches/28-fix-overflow-32bit.patch | 45 +++++++++++++++++++ .../patches/m4ri-simd_cflags_in_tests.patch | 11 ----- srcpkgs/m4ri/template | 21 ++++++--- 4 files changed, 60 insertions(+), 19 deletions(-) create mode 100644 srcpkgs/m4ri/patches/28-fix-overflow-32bit.patch delete mode 100644 srcpkgs/m4ri/patches/m4ri-simd_cflags_in_tests.patch diff --git a/common/shlibs b/common/shlibs index 9ff6ff161fb..200d683469a 100644 --- a/common/shlibs +++ b/common/shlibs @@ -4251,7 +4251,7 @@ libpolys-4.4.0.so singular-4.4.0_1 libsingular_resources-4.4.0.so singular-4.4.0_1 libbrial.so.3 brial-1.2.10_1 libbrial_groebner.so.3 brial-1.2.10_1 -libm4ri-0.0.20200125.so m4ri-20200125_1 +libm4ri.so.1 m4ri-20250128_1 libm4rie-0.0.20200125.so m4rie-20200125_1 libptytty.so.0 libptytty-2.0_1 libcoeurl.so.0.3 coeurl-0.3.0_1 diff --git a/srcpkgs/m4ri/patches/28-fix-overflow-32bit.patch b/srcpkgs/m4ri/patches/28-fix-overflow-32bit.patch new file mode 100644 index 00000000000..6ad64573693 --- /dev/null +++ b/srcpkgs/m4ri/patches/28-fix-overflow-32bit.patch @@ -0,0 +1,45 @@ +From b178ed36bdd841a76b6595edb77631886e099406 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= +Date: Mon, 3 Feb 2025 17:19:37 -0300 +Subject: [PATCH] Fix overflows in `mzd_init()` + +--- + m4ri/mmc.h | 4 ++++ + m4ri/mzd.c | 5 ++--- + 2 files changed, 6 insertions(+), 3 deletions(-) + +diff --git a/m4ri/mmc.h b/m4ri/mmc.h +index e6db4ca..3e97391 100644 +--- a/m4ri/mmc.h ++++ b/m4ri/mmc.h +@@ -72,6 +72,10 @@ typedef struct _mm_block { + * \return Pointer to allocated memory block. + */ + static inline void *m4ri_mmc_calloc(size_t count, size_t size) { ++ if (size && count > SIZE_MAX/size) { ++ m4ri_die("m4ri_mmc_calloc: overflow in multiplication\n"); ++ return NULL; /* unreachable */ ++ } + size_t total_size = count * size; + void *ret = m4ri_mmc_malloc(total_size); + memset((char *)ret, 0, total_size); +diff --git a/m4ri/mzd.c b/m4ri/mzd.c +index ba04b7c..ac62c5c 100644 +--- a/m4ri/mzd.c ++++ b/m4ri/mzd.c +@@ -144,13 +144,12 @@ mzd_t *mzd_init(rci_t r, rci_t c) { + mzd_t *A = mzd_t_malloc(); + A->nrows = r; + A->ncols = c; +- A->width = (c + m4ri_radix - 1) / m4ri_radix; ++ A->width = c > 0 ? (c - 1) / m4ri_radix + 1 : 0; + A->rowstride = ((A->width & 1) == 0) ? A->width : A->width + 1; + A->high_bitmask = __M4RI_LEFT_BITMASK(c % m4ri_radix); + A->flags = (A->high_bitmask != m4ri_ffff) ? mzd_flag_nonzero_excess : 0; + if (r && c) { +- size_t block_words = r * A->rowstride; +- A->data = m4ri_mmc_calloc(block_words, sizeof(word)); ++ A->data = m4ri_mmc_calloc(r, sizeof(word) * A->rowstride); + } else { + A->data = NULL; + } diff --git a/srcpkgs/m4ri/patches/m4ri-simd_cflags_in_tests.patch b/srcpkgs/m4ri/patches/m4ri-simd_cflags_in_tests.patch deleted file mode 100644 index ffa64b120fc..00000000000 --- a/srcpkgs/m4ri/patches/m4ri-simd_cflags_in_tests.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/tests/Makefile.in 2020-01-25 01:34:59.000000000 -0300 -+++ b/tests/Makefile.in 2021-11-10 08:13:46.505793446 -0300 -@@ -609,7 +609,7 @@ - TOPBUILDDIR = $(builddir)/.. - DEFINES = - # include TOPBUILDIR for m4ri_config.h --AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -D_XOPEN_SOURCE=600 $(DEFINES) @OPENMP_CFLAGS@ @PAPI_CFLAGS@ -+AM_CFLAGS = -I$(TOPSRCDIR) -I$(TOPBUILDDIR) -D_XOPEN_SOURCE=600 $(DEFINES) $(SIMD_CFLAGS) $(OPENMP_CFLAGS) $(PAPI_CFLAGS) - STAGEDIR := $(realpath -s $(TOPBUILDDIR)/.libs) - AM_LDFLAGS = -L$(STAGEDIR) -Wl,-rpath,$(STAGEDIR) -lm4ri $(LIBM) @PAPI_LDFLAGS@ @PAPI_LIBS@ -no-install - test_smallops_SOURCES = test_smallops.c testing.c testing.h diff --git a/srcpkgs/m4ri/template b/srcpkgs/m4ri/template index 56e60ed16f5..2d7041d9591 100644 --- a/srcpkgs/m4ri/template +++ b/srcpkgs/m4ri/template @@ -1,17 +1,24 @@ # Template file for 'm4ri' pkgname=m4ri -version=20200125 -revision=2 +version=20250128 +revision=1 build_style=gnu-configure -configure_args="--enable-openmp ax_cv_have_sse3_ext=no ax_cv_have_ssse3_ext=no" +# use defaults for cache sizes instead of build machine +configure_args="--enable-openmp --with-cachesize=0:0:0" hostmakedepends="pkg-config" makedepends="libgomp-devel libpng-devel" short_desc="Library for fast arithmetic with dense matrices over GF(2)" -maintainer="Eloi Torrents " +maintainer="Eloi Torrents " license="GPL-2.0-or-later" -homepage="https://bitbucket.org/malb/m4ri" -distfiles="https://bitbucket.org/malb/m4ri/downloads/${pkgname}-${version}.tar.gz" -checksum=0dfb34aed351882a0f2281535ea6f81c690a5efeb14edab131d9ba0dffe44863 +homepage="https://github.com/malb/m4ri" +changelog="https://github.com/malb/m4ri#history" +distfiles="https://github.com/malb/m4ri/releases/download/${version}/m4ri-${version}.tar.gz" +checksum=b4098db651483c0e1506c16f79091eba02f41dadbacf1bb25be8eb97e5515f96 + +pre_check() { + # the testsuite is very slow when run in parallel! + unset makejobs +} m4ri-devel_package() { short_desc+=" - development files"