[gnome-autoar] extractor: Propagate libarchive errors when metadata is encrypted



commit b26de9d21eb596136bbd87ec734540262523f3ba
Author: Ignacy KuchciƄski <ignacykuchcinski gmail com>
Date:   Thu Jan 27 14:50:47 2022 +0100

    extractor: Propagate libarchive errors when metadata is encrypted
    
    Currently, when trying to extract password protected 7z/RAR archives
    with encrypted file lists, the reported error message is "empty
    archive".
    
    This message is not helpful and may be confusing for users.
    
    To fix this situation, propagate libarchive errors by swapping the
    "empty archive" and "autoar_common_g_error_new_a" statements.
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-autoar/-/issues/26

 gnome-autoar/autoar-extractor.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
---
diff --git a/gnome-autoar/autoar-extractor.c b/gnome-autoar/autoar-extractor.c
index 7b8e049..e782526 100644
--- a/gnome-autoar/autoar-extractor.c
+++ b/gnome-autoar/autoar-extractor.c
@@ -1725,22 +1725,22 @@ autoar_extractor_step_scan_toplevel (AutoarExtractor *self)
     archive_read_data_skip (a);
   }
 
-  if (self->files_list == NULL) {
+  if (r != ARCHIVE_EOF) {
     if (self->error == NULL) {
-      self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
-                                      EMPTY_ARCHIVE_ERRNO,
-                                      "\'%s\': %s",
-                                      self->source_basename,
-                                      "empty archive");
+      self->error =
+        autoar_common_g_error_new_a (a, self->source_basename);
     }
     archive_read_free (a);
     return;
   }
 
-  if (r != ARCHIVE_EOF) {
+  if (self->files_list == NULL) {
     if (self->error == NULL) {
-      self->error =
-        autoar_common_g_error_new_a (a, self->source_basename);
+      self->error = g_error_new (AUTOAR_EXTRACTOR_ERROR,
+                                      EMPTY_ARCHIVE_ERRNO,
+                                      "\'%s\': %s",
+                                      self->source_basename,
+                                      "empty archive");
     }
     archive_read_free (a);
     return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]