]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
rar: convert remaining per-entry data errors to ARCHIVE_FAILED
authorTim Kientzle <kientzle@acm.org>
Sun, 3 May 2026 23:25:55 +0000 (16:25 -0700)
committerTim Kientzle <kientzle@acm.org>
Tue, 5 May 2026 20:39:27 +0000 (13:39 -0700)
Follow-up to 4f148608.  A code review found additional ARCHIVE_FATAL
returns in RAR4 data-decode paths that should be ARCHIVE_FAILED so the
caller can move on to the next entry:

  read_data_block      Truncated RAR file data
  read_data_compressed PPMd "Invalid symbol" (3 sites)
  parse_codes          Zero window size is invalid
  add_value            Prefix found (second site)
  make_table_recurse   Huffman tree was not created
  make_table_recurse   Invalid location to Huffman tree specified

These are all per-entry parse/decode failures.  As with the earlier
batch, the rar4 input position is tracked by rar_br_fillup so
read_data_skip will correctly advance past the damaged entry, and
RAR4 solid mode is not supported, so subsequent entries are not at
risk from a half-consumed shared decoder state.

libarchive/archive_read_support_format_rar.c

index f0ec12bb12bbea1d8ea0df6dbb8de7d8e8b14679..f930379d940d1c6aae7a01bbab3509fc4385bdda 100644 (file)
@@ -2038,7 +2038,7 @@ read_data_stored(struct archive_read *a, const void **buff, size_t *size,
   {
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "Truncated RAR file data");
-    return (ARCHIVE_FATAL);
+    return (ARCHIVE_FAILED);
   }
 
   *size = bytes_avail;
@@ -2186,7 +2186,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
         {
           archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                             "Invalid symbol");
-          return (ARCHIVE_FATAL);
+          return (ARCHIVE_FAILED);
         }
 
         switch(code)
@@ -2213,7 +2213,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
               {
                 archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                                   "Invalid symbol");
-                return (ARCHIVE_FATAL);
+                return (ARCHIVE_FAILED);
               }
               lzss_offset |= code << (i * 8);
             }
@@ -2222,7 +2222,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
             {
               archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                                 "Invalid symbol");
-              return (ARCHIVE_FATAL);
+              return (ARCHIVE_FAILED);
             }
             lzss_emit_match(rar, lzss_offset + 2, length + 32);
             rar->bytes_uncopied += length + 32;
@@ -2234,7 +2234,7 @@ read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
             {
               archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                                 "Invalid symbol");
-              return (ARCHIVE_FATAL);
+              return (ARCHIVE_FAILED);
             }
             lzss_emit_match(rar, 1, length + 4);
             rar->bytes_uncopied += length + 4;
@@ -2564,7 +2564,7 @@ parse_codes(struct archive_read *a)
     if (new_size == 0) {
       archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                         "Zero window size is invalid");
-      return (ARCHIVE_FATAL);
+      return (ARCHIVE_FAILED);
     }
     new_window = realloc(rar->lzss.window, new_size);
     if (new_window == NULL) {
@@ -2811,7 +2811,7 @@ add_value(struct archive_read *a, struct huffman_code *code, int value,
   {
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "Prefix found");
-    return (ARCHIVE_FATAL);
+    return (ARCHIVE_FAILED);
   }
 
   /* Set leaf value */
@@ -2865,13 +2865,13 @@ make_table_recurse(struct archive_read *a, struct huffman_code *code, int node,
   {
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "Huffman tree was not created");
-    return (ARCHIVE_FATAL);
+    return (ARCHIVE_FAILED);
   }
   if (node < 0 || node >= code->numentries)
   {
     archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
                       "Invalid location to Huffman tree specified");
-    return (ARCHIVE_FATAL);
+    return (ARCHIVE_FAILED);
   }
 
   currtablesize = 1 << (maxdepth - depth);