zlib/backport-Security-and-warning-fixes-for-minizip.-gvollant.patch
zhoupengcheng fce1c5536a zlib:backport upstream patch
(cherry picked from commit ee65ab90886d1240dc7ef6b6afc98012d7c18b2a)
2024-05-07 19:57:31 +08:00

72 lines
2.3 KiB
Diff

From 138c93cffb76f5c24e4ae6e81e6210428856f825 Mon Sep 17 00:00:00 2001
From: Mark Adler <fork@madler.net>
Date: Thu, 6 Oct 2022 15:49:04 -0700
Subject: [PATCH] Security and warning fixes for minizip. [gvollant]
Remove unused code and unnecessary test for free().
Reference:https://github.com/madler/zlib/commit/138c93cffb76f5c24e4ae6e81e6210428856f825
Conflict:NA
---
contrib/minizip/unzip.c | 4 +++-
contrib/minizip/zip.c | 7 +------
2 files changed, 4 insertions(+), 7 deletions(-)
diff --git a/contrib/minizip/unzip.c b/contrib/minizip/unzip.c
index 31e7056..17e668e 100644
--- a/contrib/minizip/unzip.c
+++ b/contrib/minizip/unzip.c
@@ -108,7 +108,7 @@
# define ALLOC(size) (malloc(size))
#endif
#ifndef TRYFREE
-# define TRYFREE(p) {if (p) free(p);}
+# define TRYFREE(p) { free(p);}
#endif
#define SIZECENTRALDIRITEM (0x2e)
@@ -1562,6 +1562,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_BZIP2ED;
else
{
+ TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
@@ -1582,6 +1583,7 @@ extern int ZEXPORT unzOpenCurrentFile3 (unzFile file, int* method,
pfile_in_zip_read_info->stream_initialised=Z_DEFLATED;
else
{
+ TRYFREE(pfile_in_zip_read_info->read_buffer);
TRYFREE(pfile_in_zip_read_info);
return err;
}
diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c
index 44e88a9..425aaf2 100644
--- a/contrib/minizip/zip.c
+++ b/contrib/minizip/zip.c
@@ -1471,11 +1471,6 @@ extern int ZEXPORT zipWriteInFileInZip (zipFile file,const void* buf,unsigned in
{
uLong uTotalOutBefore = zi->ci.stream.total_out;
err=deflate(&zi->ci.stream, Z_NO_FLUSH);
- if(uTotalOutBefore > zi->ci.stream.total_out)
- {
- int bBreak = 0;
- bBreak++;
- }
zi->ci.pos_in_buffered_data += (uInt)(zi->ci.stream.total_out - uTotalOutBefore) ;
}
@@ -1959,7 +1954,7 @@ extern int ZEXPORT zipRemoveExtraInfoBlock (char* pData, int* dataLen, short sHe
int retVal = ZIP_OK;
- if(pData == NULL || *dataLen < 4)
+ if(pData == NULL || dataLen == NULL || *dataLen < 4)
return ZIP_PARAMERROR;
pNewHeader = (char*)ALLOC(*dataLen);
--
2.33.0