debuginfod_find_section: Always update rc with most recent error code
authorAaron Merey <amerey@redhat.com>
Fri, 4 Nov 2022 21:22:40 +0000 (17:22 -0400)
committerAaron Merey <amerey@redhat.com>
Fri, 4 Nov 2022 21:22:40 +0000 (17:22 -0400)
debuginfod_find_section may attempt to download both the debuginfo
and executable matching the given build-id.  If neither of these
files can be found, update rc to ensure that we always return an
accurate error code in this case.

Signed-off-by: Aaron Merey <amerey@redhat.com>
debuginfod/ChangeLog
debuginfod/debuginfod-client.c

index 4d576ca..5678002 100644 (file)
@@ -1,3 +1,8 @@
+2022-11-04  Aaron Merey  <amerey@redhat.com>
+
+       * debuginfod-client.c (debuginfod_find_section): Ensure rc
+       is always updated with the most recent error code.
+
 2022-11-03  Frank Ch. Eigler <fche@redhat.com>
 
        * debuginfod.cxx (handle_buildid): Correctly manage lifetime
index f48e32c..99da05e 100644 (file)
@@ -1944,7 +1944,8 @@ debuginfod_find_section (debuginfod_client *client,
 
   if (rc == -EEXIST)
     {
-      /* The section should be found in the executable.  */
+      /* Either the debuginfo couldn't be found or the section should
+        be in the executable.  */
       fd = debuginfod_find_executable (client, build_id,
                                       build_id_len, &tmp_path);
       if (fd > 0)
@@ -1952,6 +1953,9 @@ debuginfod_find_section (debuginfod_client *client,
          rc = extract_section (fd, section, tmp_path, path);
          close (fd);
        }
+      else
+       /* Update rc so that we return the most recent error code.  */
+       rc = fd;
     }
 
   free (tmp_path);