]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
rar: Fix double free with over 4 billion nodes (#2598)
authorTobias Stoeckmann <stoeckmann@users.noreply.github.com>
Sun, 11 May 2025 00:17:19 +0000 (02:17 +0200)
committerGitHub <noreply@github.com>
Sun, 11 May 2025 00:17:19 +0000 (17:17 -0700)
If a system is capable of handling 4 billion nodes in memory, a double
free could occur because of an unsigned integer overflow leading to a
realloc call with size argument of 0. Eventually, the client will
release that memory again, triggering a double free.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
libarchive/archive_read_support_format_rar.c

index 542532dd7bcf6eb37d69137801c50e028c214785..197469b9761ffba75efa7abe507cb7859d8a6adb 100644 (file)
@@ -335,8 +335,8 @@ struct rar
   int found_first_header;
   char has_endarc_header;
   struct data_block_offsets *dbo;
-  unsigned int cursor;
-  unsigned int nodes;
+  size_t cursor;
+  size_t nodes;
   char filename_must_match;
 
   /* LZSS members */
@@ -1192,7 +1192,7 @@ archive_read_format_rar_seek_data(struct archive_read *a, int64_t offset,
     int whence)
 {
   int64_t client_offset, ret;
-  unsigned int i;
+  size_t i;
   struct rar *rar = (struct rar *)(a->format->data);
 
   if (rar->compression_method == COMPRESS_METHOD_STORE)