2021-01-15 22:18:51 +00:00
|
|
|
{ lib, stdenv, fetchurl
|
2020-04-24 23:36:52 +00:00
|
|
|
, bzip2
|
|
|
|
, enableNLS ? false, libnatspec
|
|
|
|
}:
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "unzip";
|
|
|
|
version = "6.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-09-18 10:52:07 +00:00
|
|
|
url = "mirror://sourceforge/infozip/unzip${lib.replaceStrings ["."] [""] version}.tar.gz";
|
2020-04-24 23:36:52 +00:00
|
|
|
sha256 = "0dxx11knh3nk95p2gg2ak777dd11pr7jx5das2g49l262scrcv83";
|
|
|
|
};
|
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
|
|
|
patchFlags = [ "-p1" "-F3" ];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
./CVE-2014-8139.diff
|
|
|
|
./CVE-2014-8140.diff
|
|
|
|
./CVE-2014-8141.diff
|
|
|
|
./CVE-2014-9636.diff
|
|
|
|
./CVE-2015-7696.diff
|
|
|
|
./CVE-2015-7697.diff
|
|
|
|
./CVE-2014-9913.patch
|
|
|
|
./CVE-2016-9844.patch
|
|
|
|
./CVE-2018-18384.patch
|
|
|
|
./dont-hardcode-cc.patch
|
|
|
|
(fetchurl {
|
|
|
|
url = "https://github.com/madler/unzip/commit/41beb477c5744bc396fa1162ee0c14218ec12213.patch";
|
|
|
|
name = "CVE-2019-13232-1.patch";
|
|
|
|
sha256 = "04jzd6chg9fw4l5zadkfsrfm5llrd7vhd1dgdjjd29nrvkrjyn14";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
|
|
|
url = "https://github.com/madler/unzip/commit/47b3ceae397d21bf822bc2ac73052a4b1daf8e1c.patch";
|
|
|
|
name = "CVE-2019-13232-2.patch";
|
|
|
|
sha256 = "0iy2wcjyvzwrjk02iszwcpg85fkjxs1bvb9isvdiywszav4yjs32";
|
|
|
|
})
|
|
|
|
(fetchurl {
|
|
|
|
url = "https://github.com/madler/unzip/commit/6d351831be705cc26d897db44f878a978f4138fc.patch";
|
|
|
|
name = "CVE-2019-13232-3.patch";
|
|
|
|
sha256 = "1jvs7dkdqs97qnsqc6hk088alhv8j4c638k65dbib9chh40jd7pf";
|
|
|
|
})
|
2022-08-12 12:06:08 +00:00
|
|
|
(fetchurl {
|
2022-09-30 11:47:45 +00:00
|
|
|
urls = [
|
|
|
|
# original link (will be dead eventually):
|
|
|
|
"https://sources.debian.org/data/main/u/unzip/6.0-26%2Bdeb11u1/debian/patches/06-initialize-the-symlink-flag.patch"
|
|
|
|
|
|
|
|
"https://gist.github.com/veprbl/41261bb781571e2246ea42d3f37795f5/raw/d8533d8c6223150f76b0f31aec03e185fcde3579/06-initialize-the-symlink-flag.patch"
|
|
|
|
];
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "1h00djdvgjhwfb60wl4qrxbyfsbbnn1qw6l2hkldnif4m8f8r1zj";
|
|
|
|
})
|
2023-02-02 18:25:31 +00:00
|
|
|
(fetchurl {
|
|
|
|
urls = [
|
|
|
|
# original link (will be dead eventually):
|
|
|
|
"https://sources.debian.org/data/main/u/unzip/6.0-27/debian/patches/28-cve-2022-0529-and-cve-2022-0530.patch"
|
|
|
|
|
|
|
|
"https://web.archive.org/web/20230106200319/https://sources.debian.org/data/main/u/unzip/6.0-27/debian/patches/28-cve-2022-0529-and-cve-2022-0530.patch"
|
|
|
|
];
|
|
|
|
sha256 = "sha256-on79jElQ+z2ULWAq14RpluAqr9d6itHiZwDkKubBzTc=";
|
|
|
|
})
|
2023-07-15 17:15:38 +00:00
|
|
|
# Clang 16 makes implicit declarations an error by default for C99 and newer, causing the
|
|
|
|
# configure script to fail to detect errno and the directory libraries on Darwin.
|
|
|
|
./implicit-declarations-fix.patch
|
2021-01-15 22:18:51 +00:00
|
|
|
] ++ lib.optional enableNLS
|
2020-04-24 23:36:52 +00:00
|
|
|
(fetchurl {
|
2022-02-10 20:34:41 +00:00
|
|
|
url = "https://gitweb.gentoo.org/repo/gentoo.git/plain/app-arch/unzip/files/unzip-6.0-natspec.patch?id=56bd759df1d0c750a065b8c845e93d5dfa6b549d";
|
2020-04-24 23:36:52 +00:00
|
|
|
name = "unzip-6.0-natspec.patch";
|
|
|
|
sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1";
|
|
|
|
});
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
nativeBuildInputs = [ bzip2 ];
|
2021-01-15 22:18:51 +00:00
|
|
|
buildInputs = [ bzip2 ] ++ lib.optional enableNLS libnatspec;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
makefile = "unix/Makefile";
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
NIX_LDFLAGS = "-lbz2" + lib.optionalString enableNLS " -lnatspec";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"generic"
|
|
|
|
"D_USE_BZ2=-DUSE_BZIP2"
|
|
|
|
"L_BZ2=-lbz2"
|
2022-08-12 12:06:08 +00:00
|
|
|
]
|
|
|
|
# `lchmod` is not available on Linux, so we remove it to fix "not supported" errors (when the zip file contains symlinks).
|
|
|
|
# Alpine (musl) and Debian (glibc) also add this flag.
|
2024-09-26 11:04:55 +00:00
|
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ "LOCAL_UNZIP=-DNO_LCHMOD" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
sed -i -e 's@CF="-O3 -Wall -I. -DASM_CRC $(LOC)"@CF="-O3 -Wall -I. -DASM_CRC -DLARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(LOC)"@' unix/Makefile
|
|
|
|
'';
|
|
|
|
|
|
|
|
installFlags = [
|
2021-02-05 17:12:51 +00:00
|
|
|
"prefix=${placeholder "out"}"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "http://www.info-zip.org";
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Extraction utility for archives compressed in .zip format";
|
2024-01-02 11:29:13 +00:00
|
|
|
license = lib.licenses.info-zip;
|
2021-01-15 22:18:51 +00:00
|
|
|
platforms = lib.platforms.all;
|
2024-06-24 18:47:55 +00:00
|
|
|
maintainers = with lib.maintainers; [ RossComputerGuy ];
|
2023-10-09 19:29:22 +00:00
|
|
|
mainProgram = "unzip";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|