From f126749a88c536789a619fbb758618f3d3074403 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Mon, 25 Nov 2024 15:49:01 +0100 Subject: [PATCH 1/2] zip: include gentoo patches --- ...ffer-overflow-on-utf8-rh-bug-2165653.patch | 12 ------ pkgs/by-name/zi/zip/package.nix | 40 +++++++++++++++---- 2 files changed, 32 insertions(+), 20 deletions(-) delete mode 100644 pkgs/by-name/zi/zip/buffer-overflow-on-utf8-rh-bug-2165653.patch diff --git a/pkgs/by-name/zi/zip/buffer-overflow-on-utf8-rh-bug-2165653.patch b/pkgs/by-name/zi/zip/buffer-overflow-on-utf8-rh-bug-2165653.patch deleted file mode 100644 index 2ee3fff0db54..000000000000 --- a/pkgs/by-name/zi/zip/buffer-overflow-on-utf8-rh-bug-2165653.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff -urp zip30/fileio.c zip30/fileio.c ---- zip30/fileio.c 2008-05-29 03:13:24.000000000 +0300 -+++ zip30/fileio.c 2023-05-02 12:19:50.488314853 +0300 -@@ -3502,7 +3502,7 @@ zwchar *local_to_wide_string(local_strin - if ((wc_string = (wchar_t *)malloc((wsize + 1) * sizeof(wchar_t))) == NULL) { - ZIPERR(ZE_MEM, "local_to_wide_string"); - } -- wsize = mbstowcs(wc_string, local_string, strlen(local_string) + 1); -+ wsize = mbstowcs(wc_string, local_string, wsize + 1); - wc_string[wsize] = (wchar_t) 0; - - /* in case wchar_t is not zwchar */ diff --git a/pkgs/by-name/zi/zip/package.nix b/pkgs/by-name/zi/zip/package.nix index 2c225489a346..19a16cd40a0e 100644 --- a/pkgs/by-name/zi/zip/package.nix +++ b/pkgs/by-name/zi/zip/package.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, enableNLS ? false, libnatspec ? null, libiconv }: +{ lib, stdenv, fetchurl, enableNLS ? false, libnatspec ? null, libiconv, fetchpatch }: assert enableNLS -> libnatspec != null; @@ -13,11 +13,11 @@ stdenv.mkDerivation rec { ]; sha256 = "0sb3h3067pzf3a7mlxn1hikpcjrsvycjcnj9hl9b1c3ykcgvps7h"; }; - prePatch = '' - substituteInPlace unix/Makefile --replace 'CC = cc' "" - ''; - hardeningDisable = [ "format" ]; + postPatch = '' + substituteInPlace unix/Makefile --replace 'CC = cc' "" + substituteInPlace unix/configure --replace-fail "O3" "O2" + ''; makefile = "unix/Makefile"; buildFlags = if stdenv.hostPlatform.isCygwin then [ "cygwin" ] else [ "generic" ]; @@ -33,11 +33,35 @@ stdenv.mkDerivation rec { ./fix-memset-detection.patch # Implicit declaration of `closedir` and `opendir` cause dirent detection to fail with clang 16. ./fix-implicit-declarations.patch - # Buffer overflow on Unicode characters in path names - # https://bugzilla.redhat.com/show_bug.cgi?id=2165653 - ./buffer-overflow-on-utf8-rh-bug-2165653.patch # Fixes forward declaration errors with timezone.c ./fix-time.h-not-included.patch + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-pic.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-OXgC9KqiOpH/o/bSabt3LqtoT/xifqfkvpLLPfPz+1c="; + }) + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-no-crypt.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-9bwV+uKST828PcRVbICs8xwz9jcIPk26gxLBbiEeta4="; + }) + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-format-security.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-YmGKivZ0iFCFmPjVYuOv9D8Y0xG2QnWOpas8gMgoQ3M="; + }) + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-exec-stack.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-akJFY+zGijPWCwaAL/xxCN4wQpVFBHkLMo2HowrSn/M="; + }) + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-build.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-MiupD7W+sxiRTsB5viKAiI4QeqtZC6VttfJktdt1ucI="; + }) + # Buffer overflow on Unicode characters in path names + # https://bugzilla.redhat.com/show_bug.cgi?id=2165653 + # (included among other changes below) + (fetchpatch { + url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-zipnote-freeze.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; + hash = "sha256-EVr7YS3IytnCRjAYUlkg05GA/kaAY9NRFG7uDt0QLAY="; + }) ] ++ lib.optionals (enableNLS && !stdenv.hostPlatform.isCygwin) [ ./natspec-gentoo.patch.bz2 ]; buildInputs = lib.optional enableNLS libnatspec From 584da3b7cef1e40dc3e31e0112e2a995e5f145f3 Mon Sep 17 00:00:00 2001 From: FliegendeWurst <2012gdwu+github@posteo.de> Date: Tue, 26 Nov 2024 17:38:50 +0100 Subject: [PATCH 2/2] zip: include patch to fix build with GCC 14 Co-authored-by: Emily --- .../zi/zip/12-fix-build-with-gcc-14.patch | 56 +++++++++++++++++++ .../by-name/zi/zip/fix-memset-detection.patch | 15 ----- pkgs/by-name/zi/zip/package.nix | 12 ++-- 3 files changed, 64 insertions(+), 19 deletions(-) create mode 100644 pkgs/by-name/zi/zip/12-fix-build-with-gcc-14.patch delete mode 100644 pkgs/by-name/zi/zip/fix-memset-detection.patch diff --git a/pkgs/by-name/zi/zip/12-fix-build-with-gcc-14.patch b/pkgs/by-name/zi/zip/12-fix-build-with-gcc-14.patch new file mode 100644 index 000000000000..58d070a3c2b9 --- /dev/null +++ b/pkgs/by-name/zi/zip/12-fix-build-with-gcc-14.patch @@ -0,0 +1,56 @@ +From: Santiago Vila +Subject: Fix build with gcc-14 +Bug-Debian: https://bugs.debian.org/1075706 +X-Debian-version: 3.0-14 + +--- a/unix/configure ++++ b/unix/configure +@@ -514,14 +514,16 @@ + echo Check for $func + echo "int main(){ $func(); return 0; }" > conftest.c + $CC $BFLAG -o conftest conftest.c >/dev/null 2>/dev/null +- [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`" ++# glibc-based systems do not need this ++# [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_`echo $func | tr '[a-z]' '[A-Z]'`" + done + + + echo Check for memset + echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c + $CC -o conftest conftest.c >/dev/null 2>/dev/null +-[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM" ++# glibc-based systems do not need this ++# [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM" + + + echo Check for memmove +@@ -551,7 +553,8 @@ + } + _EOF_ + $CC $CFLAGS -c conftest.c >/dev/null 2>/dev/null +-[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO" ++# glibc-based systems do not need this ++# [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_ERRNO" + + + echo Check for directory libraries +@@ -567,7 +570,8 @@ + $CC -o conftest conftest.c -l$lib >/dev/null 2>/dev/null + [ $? -eq 0 ] && OPT=-l$lib && break + done +- if [ ${OPT} ]; then ++ # glibc-based systems do not need this ++ if true; then + LFLAGS2="${LFLAGS2} ${OPT}" + else + CFLAGS="${CFLAGS} -DNO_DIR" +@@ -629,7 +633,8 @@ + } + _EOF_ + $CC ${CFLAGS} -c conftest.c > /dev/null 2>/dev/null +-[ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC" ++# glibc-based systems do not need this ++# [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DNO_VALLOC" + + + echo Check for /usr/local/bin and /usr/local/man diff --git a/pkgs/by-name/zi/zip/fix-memset-detection.patch b/pkgs/by-name/zi/zip/fix-memset-detection.patch deleted file mode 100644 index 55bda33a2573..000000000000 --- a/pkgs/by-name/zi/zip/fix-memset-detection.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff -ur a/unix/configure b/unix/configure ---- a/unix/configure 2008-06-19 21:32:20.000000000 -0600 -+++ b/unix/configure 2023-07-11 10:02:57.809867694 -0600 -@@ -519,7 +519,10 @@ - - - echo Check for memset --echo "int main(){ char k; memset(&k,0,0); return 0; }" > conftest.c -+cat > conftest.c << _EOF_ -+#include -+int main(){ char k; memset(&k,0,0); return 0; } -+_EOF_ - $CC -o conftest conftest.c >/dev/null 2>/dev/null - [ $? -ne 0 ] && CFLAGS="${CFLAGS} -DZMEM" - diff --git a/pkgs/by-name/zi/zip/package.nix b/pkgs/by-name/zi/zip/package.nix index 19a16cd40a0e..85b81e0f309b 100644 --- a/pkgs/by-name/zi/zip/package.nix +++ b/pkgs/by-name/zi/zip/package.nix @@ -27,14 +27,18 @@ stdenv.mkDerivation rec { ]; patches = [ - # Trying to use `memset` without declaring it is flagged as an error with clang 16, causing - # the `configure` script to incorrectly define `ZMEM`. That causes the build to fail due to - # incompatible redeclarations of `memset`, `memcpy`, and `memcmp` in `zip.h`. - ./fix-memset-detection.patch # Implicit declaration of `closedir` and `opendir` cause dirent detection to fail with clang 16. ./fix-implicit-declarations.patch # Fixes forward declaration errors with timezone.c ./fix-time.h-not-included.patch + # Without this patch, we get a runtime failures with GCC 14 when building OpenJDK 8: + # + # zip I/O error: No such file or directory + # zip error: Could not create output file (was replacing the original zip file) + # make[2]: *** [CreateJars.gmk:659: /build/source/build/linux-x86_64-normal-server-release/images/src.zip] Error 1 + # + # Source: Debian + ./12-fix-build-with-gcc-14.patch (fetchpatch { url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/zip/files/zip-3.0-pic.patch?id=d37d095fc7a2a9e4a8e904a7bf0f597fe99df85a"; hash = "sha256-OXgC9KqiOpH/o/bSabt3LqtoT/xifqfkvpLLPfPz+1c=";