From nobody Fri May 17 06:43:39 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1675690228; cv=none; d=zohomail.com; s=zohoarc; b=JfAx8ocEdufgZ1zwb7R9DDE8OPoQWpylbpZAfcwE4voLZi4Xc738sSnhBemBbeOPCY5hB5Dj1nGHDd/x/SKljhXZkVZGDjKms+dYZK1o0Vb2d0Qt17dDvbD4qQR6JHHYP/LrzBvg9TMcfi4SqlDfOIb7amGSusKpS75Kz476xbI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675690228; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=xKXXSgd3A42zuw3lRyfuxuRf6X3mMPYhFtecJsTFhjg=; b=YQqLF21mgdj3lA69LRGWN+CA5Qc++O3U9hS3vmmi40Z8hheu3aWpATryc6X11sSeG43gswLPG9HvaWyKAdOYJO6iv7l3G8aDdL5Lzsd8InffxcCE3Xp9wj5XmMIUpxHFuY7l4mMiczsX7cOsBKmt6/QTpQbmrIUjHUdhqTwT4zo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675690228489214.81387257172526; Mon, 6 Feb 2023 05:30:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pP1ZI-0004yi-FQ; Mon, 06 Feb 2023 08:30:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP1ZF-0004xh-U5 for qemu-devel@nongnu.org; Mon, 06 Feb 2023 08:29:57 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pP1ZE-0003fc-6s for qemu-devel@nongnu.org; Mon, 06 Feb 2023 08:29:57 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-586-P9E5FcBvP1692uIk2EahEQ-1; Mon, 06 Feb 2023 08:29:51 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4C8BA101A52E; Mon, 6 Feb 2023 13:29:51 +0000 (UTC) Received: from localhost (unknown [10.39.193.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0ABB7C15BA0; Mon, 6 Feb 2023 13:29:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1675690195; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xKXXSgd3A42zuw3lRyfuxuRf6X3mMPYhFtecJsTFhjg=; b=GcccugMNFb8OkiKVqAlO8SHHlLQy56v1ENnKh+51P9N+/wv5NRepEjOMp/D3Lzg/VfNo3C DZjOqqguAbjOEiyIvstMW7es3Ih9ignaPdssHj++vbmPqP94U5tWvI1WDhpDnKPqhNZb1C 4ygcE9cxybl/t86ciOmftuX0iRZS4Nc= X-MC-Unique: P9E5FcBvP1692uIk2EahEQ-1 From: Hanna Czenczek To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, Hanna Czenczek , Kevin Wolf , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= Subject: [PATCH] curl: Fix error path in curl_open() Date: Mon, 6 Feb 2023 14:29:49 +0100 Message-Id: <20230206132949.92917-1-hreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=hreitz@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1675690230561100002 g_hash_table_destroy() and g_hash_table_foreach_remove() (called by curl_drop_all_sockets()) both require the table to be non-NULL, or will print assertion failures (just print, no abort). There are several paths in curl_open() that can lead to the out_noclean label without s->sockets being allocated, so clean it only if it has been allocated. Example reproducer: $ qemu-img info -f http '' qemu-img: GLib: g_hash_table_foreach_remove: assertion 'hash_table !=3D NUL= L' failed qemu-img: GLib: g_hash_table_destroy: assertion 'hash_table !=3D NULL' fail= ed qemu-img: Could not open '': http curl driver cannot handle the URL '' (doe= s not start with 'http://') Closes: https://gitlab.com/qemu-project/qemu/-/issues/1475 Suggested-by: Daniel P. Berrang=C3=A9 Signed-off-by: Hanna Czenczek Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- block/curl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/curl.c b/block/curl.c index cbada22e9e..ba9977af5a 100644 --- a/block/curl.c +++ b/block/curl.c @@ -850,8 +850,10 @@ out_noclean: g_free(s->username); g_free(s->proxyusername); g_free(s->proxypassword); - curl_drop_all_sockets(s->sockets); - g_hash_table_destroy(s->sockets); + if (s->sockets) { + curl_drop_all_sockets(s->sockets); + g_hash_table_destroy(s->sockets); + } qemu_opts_del(opts); return -EINVAL; } --=20 2.39.1