]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
debuginfod: ensure X-DEBUGINFOD-SIZE contains file size
authorAaron Merey <amerey@redhat.com>
Mon, 25 Apr 2022 15:10:46 +0000 (11:10 -0400)
committerAaron Merey <amerey@redhat.com>
Mon, 25 Apr 2022 15:10:46 +0000 (11:10 -0400)
For archived files X-DEBUGINFOD-SIZE currently contains the size of the
archive instead of the size of the uncompressed file.  Fix this.

Also add testcases to verify X-DEBUGINFOD-SIZE contains uncompressed
file sizes.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/debuginfod.cxx
tests/run-debuginfod-response-headers.sh

index adca820800774d40c023aeea3991b10ad0c0035a..4aaf41c0886eeb2d246d97d6fa68a7788ba5a916 100644 (file)
@@ -1790,7 +1790,7 @@ handle_buildid_r_match (bool internal_req_p,
           add_mhd_response_header (r, "Content-Type",
                                    "application/octet-stream");
           add_mhd_response_header (r, "X-DEBUGINFOD-SIZE",
-                                   to_string(fs.st_size).c_str());
+                                   to_string(archive_entry_size(e)).c_str());
           add_mhd_response_header (r, "X-DEBUGINFOD-ARCHIVE",
                                    b_source0.c_str());
           add_mhd_response_header (r, "X-DEBUGINFOD-FILE", file.c_str());
index 10b2ab4987e5a885b473b5f824be80a19864ad18..62c43887b6f749d62c491c0175e7e8303cb67758 100755 (executable)
@@ -86,6 +86,14 @@ grep 'X-DEBUGINFOD-FILE: ' vlog-find$PORT1.2
 grep 'X-DEBUGINFOD-SIZE: ' vlog-find$PORT1.2
 grep 'X-DEBUGINFOD-ARCHIVE: ' vlog-find$PORT1.2
 
+# Check that X-DEBUGINFOD-SIZE matches the size of each file
+for file in vlog-find$PORT1.1 vlog-find$PORT1.2
+do
+    st_size=$(stat -c%s $(tail -n 1 $file))
+    x_debuginfod_size=$(grep 'X-DEBUGINFOD-SIZE' $file | egrep -o '[0-9]+')
+    test $st_size -eq $x_debuginfod_size
+done
+
 kill $PID1
 wait $PID1
 PID1=0