patch, debuginfod

Message ID 20221103141219.GA25265@redhat.com
State New
Headers
Series patch, debuginfod |

Commit Message

Frank Ch. Eigler Nov. 3, 2022, 2:12 p.m. UTC
  Hi -

Showing diff -w to omit reindentation whitespace noise.  Maybe worth
backporting to 0.188 releases, could affect federation intermediate
servers with burst workload. 

commit ec166cf3c8d825a2f02aca448a0823de12e78991 (HEAD -> master)
Author: Frank Ch. Eigler <fche@redhat.com>
Date:   Thu Nov 3 10:07:31 2022 -0400

    debuginfod.cxx: fix coverity-found use-after-release error
    
    The debuginfod_client object lifetime needs more careful handling,
    made easier with the defer_dtor<> gadget.
    
    Signed-off-by: Frank Ch. Eigler <fche@redhat.com>
  

Patch

diff --git a/debuginfod/ChangeLog b/debuginfod/ChangeLog
index 1efa080fe337..4d576caec2a5 100644
--- a/debuginfod/ChangeLog
+++ b/debuginfod/ChangeLog
@@ -1,3 +1,8 @@ 
+2022-11-03  Frank Ch. Eigler <fche@redhat.com>
+
+	* debuginfod.cxx (handle_buildid): Correctly manage lifetime
+	of debuginfod_client federation callout object.
+
 2022-11-02  Mark Wielaard  <mark@klomp.org>
 
 	* debuginfod-client.c (extract_section): Mark static.
diff --git a/debuginfod/debuginfod.cxx b/debuginfod/debuginfod.cxx
index f46da6eff4a7..02a11477a515 100644
--- a/debuginfod/debuginfod.cxx
+++ b/debuginfod/debuginfod.cxx
@@ -2249,8 +2249,10 @@  handle_buildid (MHD_Connection* conn,
 
   int fd = -1;
   debuginfod_client *client = debuginfod_pool_begin ();
-  if (client != NULL)
-    {
+  if (client == NULL)
+    throw libc_exception(errno, "debuginfod client pool alloc");
+  defer_dtor<debuginfod_client*,void> client_closer (client, debuginfod_pool_end);
+  
   debuginfod_set_progressfn (client, & debuginfod_find_progress);
 
   if (conn)
@@ -2323,11 +2325,6 @@  and will not query the upstream servers");
                                   (const unsigned char*) buildid.c_str(),
                                   0, section.c_str(), NULL);
   
-    }
-  else
-    fd = -errno; /* Set by debuginfod_begin.  */
-  debuginfod_pool_end (client);
-
   if (fd >= 0)
     {
       if (conn != 0)