|
| 1 | +From 73331a6a0481067628f065ffe87bb1d8f787d10c Mon Sep 17 00:00:00 2001 |
| 2 | +From: Hans Wennborg < [email protected]> |
| 3 | +Date: Fri, 18 Aug 2023 11:05:33 +0200 |
| 4 | +Subject: [PATCH] Reject overflows of zip header fields in minizip. |
| 5 | + |
| 6 | +This checks the lengths of the file name, extra field, and comment |
| 7 | +that would be put in the zip headers, and rejects them if they are |
| 8 | +too long. They are each limited to 65535 bytes in length by the zip |
| 9 | +format. This also avoids possible buffer overflows if the provided |
| 10 | +fields are too long. |
| 11 | + |
| 12 | +CVE: CVE-2023-45853 |
| 13 | +Upstream-Status: Backport [https://github.com/madler/zlib/commit/73331a6a0481067628f065ffe87bb1d8f787d10c] |
| 14 | + |
| 15 | +Signed-off-by: Peter Marko < [email protected]> |
| 16 | + |
| 17 | +--- |
| 18 | + contrib/minizip/zip.c | 11 +++++++++++ |
| 19 | + 1 file changed, 11 insertions(+) |
| 20 | + |
| 21 | +diff --git a/contrib/minizip/zip.c b/contrib/minizip/zip.c |
| 22 | +index 3d3d4cadd..0446109b2 100644 |
| 23 | +--- a/contrib/minizip/zip.c |
| 24 | ++++ b/contrib/minizip/zip.c |
| 25 | +@@ -1043,6 +1043,17 @@ extern int ZEXPORT zipOpenNewFileInZip4_64(zipFile file, const char* filename, c |
| 26 | + return ZIP_PARAMERROR; |
| 27 | + #endif |
| 28 | + |
| 29 | ++ // The filename and comment length must fit in 16 bits. |
| 30 | ++ if ((filename!=NULL) && (strlen(filename)>0xffff)) |
| 31 | ++ return ZIP_PARAMERROR; |
| 32 | ++ if ((comment!=NULL) && (strlen(comment)>0xffff)) |
| 33 | ++ return ZIP_PARAMERROR; |
| 34 | ++ // The extra field length must fit in 16 bits. If the member also requires |
| 35 | ++ // a Zip64 extra block, that will also need to fit within that 16-bit |
| 36 | ++ // length, but that will be checked for later. |
| 37 | ++ if ((size_extrafield_local>0xffff) || (size_extrafield_global>0xffff)) |
| 38 | ++ return ZIP_PARAMERROR; |
| 39 | ++ |
| 40 | + zi = (zip64_internal*)file; |
| 41 | + |
| 42 | + if (zi->in_opened_file_inzip == 1) |
0 commit comments