package/lz4: add upstream security fix for CVE-2021-3520
authorPeter Korsgaard <peter@korsgaard.com>
Sun, 23 May 2021 09:52:39 +0000 (11:52 +0200)
committerYann E. MORIN <yann.morin.1998@free.fr>
Sun, 23 May 2021 11:45:59 +0000 (13:45 +0200)
Fixes a potential memory corruption with negative memmove() size.  For
details, see (NVD not yet updated):

https://security-tracker.debian.org/tracker/CVE-2021-3520

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
package/lz4/0001-Fix-potential-memory-corruption-with-negative-memmov.patch [new file with mode: 0644]
package/lz4/lz4.mk

diff --git a/package/lz4/0001-Fix-potential-memory-corruption-with-negative-memmov.patch b/package/lz4/0001-Fix-potential-memory-corruption-with-negative-memmov.patch
new file mode 100644 (file)
index 0000000..57e4e38
--- /dev/null
@@ -0,0 +1,26 @@
+From 8301a21773ef61656225e264f4f06ae14462bca7 Mon Sep 17 00:00:00 2001
+From: Jasper Lievisse Adriaanse <j@jasper.la>
+Date: Fri, 26 Feb 2021 15:21:20 +0100
+Subject: [PATCH] Fix potential memory corruption with negative memmove() size
+
+Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
+---
+ lib/lz4.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/lib/lz4.c b/lib/lz4.c
+index 5f524d0..c2f504e 100644
+--- a/lib/lz4.c
++++ b/lib/lz4.c
+@@ -1749,7 +1749,7 @@ LZ4_decompress_generic(
+                  const size_t dictSize         /* note : = 0 if noDict */
+                  )
+ {
+-    if (src == NULL) { return -1; }
++    if ((src == NULL) || (outputSize < 0)) { return -1; }
+     {   const BYTE* ip = (const BYTE*) src;
+         const BYTE* const iend = ip + srcSize;
+-- 
+2.20.1
+
index e0236c05b1250b64ea5a2991729d985b429fd62c..9b9b6198c3fa991bf4cf7943050cc5519a712801 100644 (file)
@@ -17,6 +17,9 @@ LZ4_CPE_ID_VENDOR = yann_collet
 # See https://github.com/lz4/lz4/issues/818
 LZ4_IGNORE_CVES += CVE-2014-4715
 
+# 0001-Fix-potential-memory-corruption-with-negative-memmov.patch
+LZ4_IGNORE_CVES += CVE-2021-3520
+
 ifeq ($(BR2_STATIC_LIBS),y)
 LZ4_MAKE_OPTS += BUILD_SHARED=no
 else ifeq ($(BR2_SHARED_LIBS),y)