mirror of
https://github.com/zlib-ng/minizip-ng
synced 2025-03-28 21:13:18 +00:00
Reject overflows of zip header fields in minizip compat
This checks the lengths of the file name, and comment that would be put in the zip headers, and rejects them if they are too long. They are each limited to 65535 bytes in length by the zip format. This also avoids possible buffer overflows if the provided fields are too long. See #736.
This commit is contained in:
parent
ef3ef9a4b8
commit
2c2d6e5940
@ -463,6 +463,12 @@ int zipOpenNewFileInZip5(zipFile file, const char *filename, const zip_fileinfo
|
||||
if (!compat)
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
// The filename and comment length must fit in 16 bits.
|
||||
if (filename && strlen(filename) > 0xffff)
|
||||
return ZIP_PARAMERROR;
|
||||
if (comment && strlen(comment) > 0xffff)
|
||||
return ZIP_PARAMERROR;
|
||||
|
||||
memset(&file_info, 0, sizeof(file_info));
|
||||
|
||||
if (zipfi) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user