p7zip: vendor debian patches

A few months ago I moved these patches to the new debian alsa instance [1], but
it looks like their `sha256`s on the tag at the remote have changed again.

It doesn't appear that debian's source remote is stable in the way we need it to
be; let's just vendor the patches to avoid future issues.

[1] https://github.com/NixOS/nixpkgs/pull/41769

+61 -11
+23
pkgs/tools/archivers/p7zip/12-CVE-2016-9296.patch
··· 1 + From: Robert Luberda <robert@debian.org> 2 + Date: Sat, 19 Nov 2016 08:48:08 +0100 3 + Subject: Fix nullptr dereference (CVE-2016-9296) 4 + 5 + Patch taken from https://sourceforge.net/p/p7zip/bugs/185/ 6 + --- 7 + CPP/7zip/Archive/7z/7zIn.cpp | 3 ++- 8 + 1 file changed, 2 insertions(+), 1 deletion(-) 9 + 10 + diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp 11 + index b0c6b98..7c6dde2 100644 12 + --- a/CPP/7zip/Archive/7z/7zIn.cpp 13 + +++ b/CPP/7zip/Archive/7z/7zIn.cpp 14 + @@ -1097,7 +1097,8 @@ HRESULT CInArchive::ReadAndDecodePackedStreams( 15 + if (CrcCalc(data, unpackSize) != folders.FolderCRCs.Vals[i]) 16 + ThrowIncorrect(); 17 + } 18 + - HeadersSize += folders.PackPositions[folders.NumPackStreams]; 19 + + if (folders.PackPositions) 20 + + HeadersSize += folders.PackPositions[folders.NumPackStreams]; 21 + return S_OK; 22 + } 23 +
+35
pkgs/tools/archivers/p7zip/13-CVE-2017-17969.patch
··· 1 + From: =?utf-8?q?Antoine_Beaupr=C3=A9?= <anarcat@debian.org> 2 + Date: Fri, 2 Feb 2018 11:11:41 +0100 3 + Subject: Heap-based buffer overflow in 7zip/Compress/ShrinkDecoder.cpp 4 + 5 + Origin: vendor, https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/27d7/attachment/CVE-2017-17969.patch 6 + Forwarded: https://sourceforge.net/p/p7zip/bugs/_discuss/thread/0920f369/#27d7 7 + Bug: https://sourceforge.net/p/p7zip/bugs/204/ 8 + Bug-Debian: https://bugs.debian.org/888297 9 + Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2017-17969 10 + Reviewed-by: Salvatore Bonaccorso <carnil@debian.org> 11 + Last-Update: 2018-02-01 12 + Applied-Upstream: 18.00-beta 13 + --- 14 + CPP/7zip/Compress/ShrinkDecoder.cpp | 7 ++++++- 15 + 1 file changed, 6 insertions(+), 1 deletion(-) 16 + 17 + diff --git a/CPP/7zip/Compress/ShrinkDecoder.cpp b/CPP/7zip/Compress/ShrinkDecoder.cpp 18 + index 80b7e67..ca37764 100644 19 + --- a/CPP/7zip/Compress/ShrinkDecoder.cpp 20 + +++ b/CPP/7zip/Compress/ShrinkDecoder.cpp 21 + @@ -121,8 +121,13 @@ HRESULT CDecoder::CodeReal(ISequentialInStream *inStream, ISequentialOutStream * 22 + { 23 + _stack[i++] = _suffixes[cur]; 24 + cur = _parents[cur]; 25 + + if (cur >= kNumItems || i >= kNumItems) 26 + + break; 27 + } 28 + - 29 + + 30 + + if (cur >= kNumItems || i >= kNumItems) 31 + + break; 32 + + 33 + _stack[i++] = (Byte)cur; 34 + lastChar2 = (Byte)cur; 35 +
+3 -11
pkgs/tools/archivers/p7zip/default.nix
··· 1 - { stdenv, fetchurl, fetchpatch }: 1 + { stdenv, fetchurl }: 2 2 3 3 stdenv.mkDerivation rec { 4 4 name = "p7zip-${version}"; ··· 10 10 }; 11 11 12 12 patches = [ 13 - (fetchpatch rec { 14 - name = "CVE-2016-9296.patch"; 15 - url = "https://salsa.debian.org/debian/p7zip/raw/debian/${version}+dfsg-6/debian/patches/12-${name}"; 16 - sha256 = "09wbkzai46bwm8zmplsz0m4jck3qn7snr68i9p1gsih300zidj0m"; 17 - }) 18 - (fetchpatch rec { 19 - name = "CVE-2017-17969.patch"; 20 - url = "https://salsa.debian.org/debian/p7zip/raw/debian/${version}+dfsg-6/debian/patches/13-${name}"; 21 - sha256 = "00pycdwx6gw7w591bg54ym6zhbxgn47p3zhms6mnmaycfzw09mkn"; 22 - }) 13 + ./12-CVE-2016-9296.patch 14 + ./13-CVE-2017-17969.patch 23 15 ]; 24 16 25 17 # Default makefile is full of impurities on Darwin. The patch doesn't hurt Linux so I'm leaving it unconditional