Blame SOURCES/CVE-2018-16548.part2.patch

5cf55c
From d2e5d5c53212e54a97ad64b793a4389193fec687 Mon Sep 17 00:00:00 2001
5cf55c
From: jmoellers <josef.moellers@suse.com>
5cf55c
Date: Fri, 7 Sep 2018 11:49:28 +0200
5cf55c
Subject: [PATCH] Avoid memory leak from __zzip_parse_root_directory().
5cf55c
5cf55c
---
5cf55c
 zzip/zip.c | 25 ++-----------------------
5cf55c
 1 file changed, 2 insertions(+), 23 deletions(-)
5cf55c
5cf55c
diff --git a/zzip/zip.c b/zzip/zip.c
5cf55c
index a685280..51a1a4d 100644
5cf55c
--- a/zzip/zip.c
5cf55c
+++ b/zzip/zip.c
5cf55c
@@ -587,34 +587,13 @@ __zzip_parse_root_directory(int fd,
5cf55c
 	{
5cf55c
 	    /* If it is not assigned to *hdr_return, it will never be free()'d */
5cf55c
 	    free(hdr0);
5cf55c
-	    /* Make sure we don't free it again in case of error */
5cf55c
-	    hdr0 = NULL;
5cf55c
 	}
5cf55c
     }                           /* else zero (sane) entries */
5cf55c
 #  ifndef ZZIP_ALLOW_MODULO_ENTRIES
5cf55c
-    if (entries != zz_entries)
5cf55c
-    {
5cf55c
-	/* If it was assigned to *hdr_return, undo assignment */
5cf55c
-	if (p_reclen && hdr_return)
5cf55c
-	    *hdr_return = NULL;
5cf55c
-	/* Free it, if it was not already free()'d */
5cf55c
-	if (hdr0 != NULL)
5cf55c
-	    free(hdr0);
5cf55c
-	return ZZIP_CORRUPTED;
5cf55c
-    }
5cf55c
+    return (entries != zz_entries) ? ZZIP_CORRUPTED : 0;
5cf55c
 #  else
5cf55c
-    if (((entries & (unsigned)0xFFFF) != zz_entries)
5cf55c
-    {
5cf55c
-	/* If it was assigned to *hdr_return, undo assignment */
5cf55c
-	if (p_reclen && hdr_return)
5cf55c
-	    *hdr_return = NULL;
5cf55c
-	/* Free it, if it was not already free()'d */
5cf55c
-	if (hdr0 != NULL)
5cf55c
-	    free(hdr0);
5cf55c
-	return ZZIP_CORRUPTED;
5cf55c
-    }
5cf55c
+    return ((entries & (unsigned)0xFFFF) != zz_entries) ? ZZIP_CORRUPTED : 0;
5cf55c
 #  endif
5cf55c
-    return 0;
5cf55c
 }
5cf55c
 
5cf55c
 /* ------------------------- high-level interface ------------------------- */