public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: "Frank Ch. Eigler" <fche@redhat.com>
To: elfutils-devel@sourceware.org
Subject: patch, debuginfod
Date: Thu, 3 Nov 2022 10:12:19 -0400	[thread overview]
Message-ID: <20221103141219.GA25265@redhat.com> (raw)

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)


                 reply	other threads:[~2022-11-03 14:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221103141219.GA25265@redhat.com \
    --to=fche@redhat.com \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).