]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Avoid a read off-by-one error for UTF16 names in RAR archives.
authorJoerg Sonnenberger <joerg@bec.de>
Sat, 9 Sep 2017 15:47:32 +0000 (17:47 +0200)
committerJoerg Sonnenberger <joerg@bec.de>
Sat, 9 Sep 2017 15:47:32 +0000 (17:47 +0200)
Reported-By: OSS-Fuzz issue 573
libarchive/archive_read_support_format_rar.c

index cbb14c32dc3bbd4874390b53a2f97e3dd5167e2d..751de6979ba5412a59db4d4de7ff44b5c54fcd06 100644 (file)
@@ -1496,7 +1496,11 @@ read_header(struct archive_read *a, struct archive_entry *entry,
         return (ARCHIVE_FATAL);
       }
       filename[filename_size++] = '\0';
-      filename[filename_size++] = '\0';
+      /*
+       * Do not increment filename_size here as the computations below
+       * add the space for the terminating NUL explicitly.
+       */
+      filename[filename_size] = '\0';
 
       /* Decoded unicode form is UTF-16BE, so we have to update a string
        * conversion object for it. */