From nobody Sat Feb 7 08:28:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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=1572789429; cv=none; d=zoho.com; s=zohoarc; b=on6R8VP2n2rGHSDwtEhJIDI883H7zDO5DOMUCd7GSyDNYZYZ0YZWPNU86PL6Ceos1Tb2hRd6o9eiwK1ledWd+3VwyO2XpoTMGJm2uBZwosbjmCB8ABo3GKxbBAfVRFy9hsKBH/QN12IDUi+kEecsd0di2lhZ4Kh1p7qlpCQoEi8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572789429; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UoknNEpO8E1Y2lfeiPRItaIvvCX7V2TV7yU0f4NLuKw=; b=dfh0rKjSqsZFEqVKwPHJK3RrX6uy2SDodO+VcwsiBLo7V8owBtuWKOj5UOIfioKtP9+pyqjWID2i2v9wZcQS/YwkBHsMDk5r6r4D48Rmuq0QU3mHQ6Du1UKJ8YEmGuLzFdc9KL3gZIQutjK8K1M1N3pBv5VF/DaugnulrsmyXKU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1572789429526733.2320985735219; Sun, 3 Nov 2019 05:57:09 -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-225-XD6iOkdKP1W44e3me5UrnQ-1; Sun, 03 Nov 2019 08:54:35 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F78C47A; Sun, 3 Nov 2019 13:54:30 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3B2C4600D3; Sun, 3 Nov 2019 13:54:30 +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 F3B014E56D; Sun, 3 Nov 2019 13:54:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xA3DrlDZ005830 for ; Sun, 3 Nov 2019 08:53:47 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3AF2860874; Sun, 3 Nov 2019 13:53:47 +0000 (UTC) Received: from unknown04D3B0C4CC7D.redhat.com (ovpn-116-59.phx2.redhat.com [10.3.116.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id E477C6085E for ; Sun, 3 Nov 2019 13:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572789428; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UoknNEpO8E1Y2lfeiPRItaIvvCX7V2TV7yU0f4NLuKw=; b=WBqWMwqTLoOZNCrqzv+hrEijygalaCeXWJfsCW+gJADy/yXga+M99U6QWXf3S2tOY/6AUZ +vGd4R+LXK/fCwGfZx/A3eH/thcKoU7cBAh1isgT0HbblS1sA1nVCZ0LFlBIkit3OHVXwz UWlabUJOLI+BMt5qGdhWU5JK3kFQmLA= From: John Ferlan To: libvir-list@redhat.com Date: Sun, 3 Nov 2019 08:53:40 -0500 Message-Id: <20191103135340.3505-9-jferlan@redhat.com> In-Reply-To: <20191103135340.3505-1-jferlan@redhat.com> References: <20191103135340.3505-1-jferlan@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 8/8] tests: Fix logic to not have possible NULL deref 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.79 on 10.5.11.11 X-MC-Unique: XD6iOkdKP1W44e3me5UrnQ-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" It's possible that virBitmapNewString returns NULL with an error string (and not an allocation failure that would abort); however, if virBitmapToString is called with a NULL @bitmap, then it will fail in an ugly manner. So rather than have if (!map && !str) logic, split the checks for each variable. Found by Coverity Signed-off-by: John Ferlan --- tests/virbitmaptest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/virbitmaptest.c b/tests/virbitmaptest.c index 545e9272df..2808d9c880 100644 --- a/tests/virbitmaptest.c +++ b/tests/virbitmaptest.c @@ -682,9 +682,11 @@ test13(const void *opaque G_GNUC_UNUSED) =20 for (i =3D 0; i < G_N_ELEMENTS(strings); i++) { map =3D virBitmapNewString(strings[i]); - str =3D virBitmapToString(map, false, true); + if (!map) + goto cleanup; =20 - if (!map || !str) + str =3D virBitmapToString(map, false, true); + if (!str) goto cleanup; =20 if (STRNEQ(strings[i], str)) { --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list