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