public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* patch, debuginfod
@ 2022-11-03 14:12 Frank Ch. Eigler
  0 siblings, 0 replies; only message in thread
From: Frank Ch. Eigler @ 2022-11-03 14:12 UTC (permalink / raw)
  To: elfutils-devel

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>

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)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-03 14:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-03 14:12 patch, debuginfod Frank Ch. Eigler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).