]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: add filename to archive_exception log
authorMichael Trapp <michael.trapp@sap.com>
Tue, 17 Feb 2026 13:46:49 +0000 (14:46 +0100)
committerAaron Merey <amerey@redhat.com>
Tue, 17 Feb 2026 14:11:15 +0000 (09:11 -0500)
The current archive_exception doesn't report the filename of a broken archive,
but this information is needed to identify the affected archive.

Fix this by adding a new archive_exception to get the following log message:

  libarchive error: _FILENAME_ cannot extract file: Truncated tar archive ...

Signed-off-by: Michael Trapp <michael.trapp@sap.com>
debuginfod/debuginfod.cxx

index 9796d31214bc676e646cc104ef53ca5f5b77923f..049570ae6cf46b95850f4c26bfe7c876c3b4b651 100644 (file)
@@ -844,6 +844,11 @@ struct archive_exception: public reportable_exception
     reportable_exception(string("libarchive error: ") + msg + ": " + string(archive_error_string(a) ?: "?")) {
     inc_metric("error_count","libarchive",msg + ": " + string(archive_error_string(a) ?: "?"));
   }
+  archive_exception(struct archive* a, const string& fname, const string& msg):
+    reportable_exception(string("libarchive error: ") + fname + string(" ") + msg + ": " +
+                         string(archive_error_string(a) ?: "?")) {
+    inc_metric("error_count","libarchive",msg + ": " + string(archive_error_string(a) ?: "?"));
+  }
 };
 
 
@@ -3027,7 +3032,7 @@ handle_buildid_r_match (bool internal_req_p,
         {
           close (fd);
           unlink (tmppath);
-          throw archive_exception(a, "cannot extract file");
+          throw archive_exception(a, b_source0, "cannot extract file");
         }
 
       // Set the mtime so the fdcache file mtimes, even prefetched ones,
@@ -4702,7 +4707,7 @@ archive_classify (const string& rps, string& archive_extension, int64_t archivei
           rc = archive_read_data_into_fd (a, fd);
           if (rc != ARCHIVE_OK) {
             close (fd);
-            throw archive_exception(a, "cannot extract file");
+            throw archive_exception(a, rps, "cannot extract file");
           }
 
           // finally ... time to run elf_classify on this bad boy and update the database