]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
zip: Fix out of boundary access (#2145)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Thu, 25 Apr 2024 09:18:30 +0000 (09:18 +0000)
committerGitHub <noreply@github.com>
Thu, 25 Apr 2024 09:18:30 +0000 (11:18 +0200)
If a ZIP file contains a file with an empty name and mac-ext option is
set, then a check accesses memory out of bound of `name`.

libarchive/archive_read_support_format_zip.c

index d7b6f082eed71f2b946de595804fd950137ae8b2..7552a1a1a2f033c890fb06ad72c8b865b7cb7b5a 100644 (file)
@@ -4089,7 +4089,7 @@ slurp_central_directory(struct archive_read *a, struct archive_entry* entry,
                                 * as the actual resource fork doesn't end with '/'.
                                 */
                                size_t tmp_length = filename_length;
-                               if (name[tmp_length - 1] == '/') {
+                               if (tmp_length > 0 && name[tmp_length - 1] == '/') {
                                        tmp_length--;
                                        r = rsrc_basename(name, tmp_length);
                                }