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