From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 409883858299 for ; Thu, 3 Nov 2022 14:12:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 409883858299 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667484741; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=qajnExnoNAdFQ0gkUxBqpHqLeolmmBq5+qeXO8UgZ5k=; b=GCyGHS6fGolhUXUcGSrKFKXwgKDL249z7DPdpytwok2CAwt/2vtlHIhhw7aiPDi1Hxtugi wuhvTSxSxLgatoEeEj4wMiLAprVX37dNis77yIxWxdYaK+qYoyCVtvSiw6EdFBtA08gCIP p0s1jPgfmVyhJEBWRzyPhY7czODwriU= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-531-rQxzJC3zPFSXwmtZEurjGQ-1; Thu, 03 Nov 2022 10:12:20 -0400 X-MC-Unique: rQxzJC3zPFSXwmtZEurjGQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 366A02A5957E for ; Thu, 3 Nov 2022 14:12:20 +0000 (UTC) Received: from redhat.com (unknown [10.2.16.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 277191121325 for ; Thu, 3 Nov 2022 14:12:20 +0000 (UTC) Received: from fche by redhat.com with local (Exim 4.94.2) (envelope-from ) id 1oqax9-0008RN-8k for elfutils-devel@sourceware.org; Thu, 03 Nov 2022 10:12:19 -0400 Date: Thu, 3 Nov 2022 10:12:19 -0400 From: "Frank Ch. Eigler" To: elfutils-devel@sourceware.org Subject: patch, debuginfod Message-ID: <20221103141219.GA25265@redhat.com> MIME-Version: 1.0 User-Agent: Mutt/1.12.0 (2019-05-25) X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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 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 + + * debuginfod.cxx (handle_buildid): Correctly manage lifetime + of debuginfod_client federation callout object. + 2022-11-02 Mark Wielaard * 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 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)