From nobody Thu May 2 17:53:40 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1614937347; cv=none; d=zohomail.com; s=zohoarc; b=PxWaZhcVWlle1bzF1e0MThSlpGd7rgxRu6KLKgYJaRS9mriNzWw1uE2sILQkwR/c6iTR6Vi/qKCKNpLCsk0Z0ZAlLqxwmGi5PCsCKwi/PqwsI8eyH0r6dXJxPZi3PaR3unFtNX33UF9Bsj0LVSmjwZctzMALTYr0/2RjP62gdS0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614937347; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=8Qzq4qzpEdupn9zN24DrWjkvoaHfZdi0SVYAKZrlFvg=; b=Wg1OCtVuGf3WWqt94g8NoRYEeZ6b4gCmvu6i/b7C7WU+ajpdl1CKvfN/89Sl268xL7nPvySXqGiZ90a1WvPXc0WR6RU39kuQyOpNSABtxD5hJHwohat2FR3BYfB03AqIsNq1qLynw0+69X1ULRD9U5GGwgXcUxvb3kBRmy6/Nvc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1614937347868783.3717989841645; Fri, 5 Mar 2021 01:42:27 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-418-YOLdtMe2PuaCzGW7Pp18Qw-1; Fri, 05 Mar 2021 04:42:23 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D449357; Fri, 5 Mar 2021 09:42:17 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 779EB1002382; Fri, 5 Mar 2021 09:42:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id AD9E718095C9; Fri, 5 Mar 2021 09:42:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 1259gB9N004195 for ; Fri, 5 Mar 2021 04:42:11 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3904F5D9C6; Fri, 5 Mar 2021 09:42:11 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 94EA95D9C0 for ; Fri, 5 Mar 2021 09:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614937345; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8Qzq4qzpEdupn9zN24DrWjkvoaHfZdi0SVYAKZrlFvg=; b=bvXpygZtps+sCo8uEYke24FQcgfHIhxrMAxCm57At+7LdWS2L3vrZuaRLyhhcZFD250X3f M5NlB1AK67LEITXi+hjej0499kd4LepkMU+/Ozq1d8o1MKCove1NnWHD62TJlsjbnrMQjk jaT3dcdlABeKwOe0YZNoeoi/SzNGTpY= X-MC-Unique: YOLdtMe2PuaCzGW7Pp18Qw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH] virFirewallApply: Fix possible NULL dereference on error Date: Fri, 5 Mar 2021 10:42:06 +0100 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Commit bbc25f0d03d443efd35381463efc81b01cb6ae96 juggled around some error reporting. Unfortunately virFirewallApply tries to report the errno stored in the firewall object and we'd try to do that when the firewall object is NULL too. Report EINVAL if 'firewall' is NULL. Found by Coverity. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virfirewall.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index c1b7d2268b..0dc0cecd53 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -766,8 +766,12 @@ virFirewallApply(virFirewallPtr firewall) goto cleanup; } if (!firewall || firewall->err) { - virReportSystemError(firewall->err, "%s", - _("Unable to create rule")); + int err =3D EINVAL; + + if (firewall) + err =3D firewall->err; + + virReportSystemError(err, "%s", _("Unable to create rule")); goto cleanup; } --=20 2.29.2