From nobody Sat May 4 06:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585560322; cv=none; d=zohomail.com; s=zohoarc; b=eYrXP8Oz8fEx1NZ81eMbWBGuzHR5uR4zTZ/OnjrtaaoeoNiwQ2eHlbaT5hKy4401DlfkJc+Xg0FOIhcBOFZt6nITPPTfkNWfSv5DhAHbBUKuP+LDc4kPcSfmtk0KaEup9PRkOGSpXtruVnLcwREWoUvYnl11a2TwFosckbyOrA8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585560322; 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=td3vaqjPeUB4lOq89evhX3PLaiYngEcwIc3sA5kUmZU=; b=NlizHFZ1r+dUuAKFNThMaosF2t6Er4rYqWD8Vhitx2BTZvMJ0dXE1PzJBYFlU/CegiikxUDBDUW5YRKAibXMWQb42eu8sdjp+VKCR6YokhtkVCjHCzos5rMskNiVDbF3FAG9bK0Ovukit+lS3sJx3bT5j+Iq9PrlZeDOoF+vIsY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 158556032265333.58558959317645; Mon, 30 Mar 2020 02:25:22 -0700 (PDT) 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-97-O1skMw9KNj2Lg5XsOpJIdg-1; Mon, 30 Mar 2020 05:25:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 77AD118A5502; Mon, 30 Mar 2020 09:25:13 +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 3745C5DA76; Mon, 30 Mar 2020 09:25:13 +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 2ED8018089CF; Mon, 30 Mar 2020 09:25:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02U9P8I1004066 for ; Mon, 30 Mar 2020 05:25:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 625CC6031F; Mon, 30 Mar 2020 09:25:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id D21A3D7678 for ; Mon, 30 Mar 2020 09:25:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585560321; 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=td3vaqjPeUB4lOq89evhX3PLaiYngEcwIc3sA5kUmZU=; b=GFOUQ4/X6xvNj+FFy9wTRkIh4mOTZ/gMBo5RjcuGs4FVfVTwFGe+Y7y4j6eP953RkfOyL8 1+dTv8W3yXQk+u/nq0/zu9qdVIf9y/XEMBUV4tz6CX6kOymu8aBX4UJPA42Io51xAVtzqQ HtMpc8HvMG4vp+SGLKdujmzuT3VCEns= X-MC-Unique: O1skMw9KNj2Lg5XsOpJIdg-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/3] Don't pass NULL to yajl_free() Date: Mon, 30 Mar 2020 11:24:58 +0200 Message-Id: <767800de72505efe743fbb04955af8700e47d926.1585560263.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.14 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" Unfortunately, yajl_free() is not NOP on NULL. It really does expect a valid pointer. Therefore, check whether the pointer we want to pass to it is NULL or not. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virjson.c | 2 +- tools/nss/libvirt_nss_leases.c | 3 ++- tools/nss/libvirt_nss_macs.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/util/virjson.c b/src/util/virjson.c index be472d49e4..dc662bf8e9 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1838,7 +1838,7 @@ virJSONValueFromString(const char *jsonstring) if (!hand) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Unable to create JSON parser")); - goto cleanup; + return NULL; } =20 /* Yajl 2 is nice enough to default to rejecting trailing garbage. */ diff --git a/tools/nss/libvirt_nss_leases.c b/tools/nss/libvirt_nss_leases.c index 7c431e4d53..015bbc4ab6 100644 --- a/tools/nss/libvirt_nss_leases.c +++ b/tools/nss/libvirt_nss_leases.c @@ -426,7 +426,8 @@ findLeases(const char *file, *addrs =3D NULL; *naddrs =3D 0; } - yajl_free(parser); + if (parser) + yajl_free(parser); free(parserState.entry.ipaddr); free(parserState.entry.macaddr); free(parserState.entry.hostname); diff --git a/tools/nss/libvirt_nss_macs.c b/tools/nss/libvirt_nss_macs.c index 05d096a348..d4b165eef6 100644 --- a/tools/nss/libvirt_nss_macs.c +++ b/tools/nss/libvirt_nss_macs.c @@ -278,7 +278,8 @@ findMACs(const char *file, *macs =3D NULL; *nmacs =3D 0; } - yajl_free(parser); + if (parser) + yajl_free(parser); for (i =3D 0; i < parserState.entry.nmacs; i++) free(parserState.entry.macs[i]); free(parserState.entry.macs); --=20 2.24.1 From nobody Sat May 4 06:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.74 as permitted sender) client-ip=216.205.24.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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=1585560324; cv=none; d=zohomail.com; s=zohoarc; b=MPjrJpfzksYDEopww90s7twd+/Vr3Q2b3RFsAm+5M86bzc5Y4mMAhxCMXCZgJBeWz7BHF0/1Ej0qF3wnHLEgnm1eTBKeiSATGsLDFmYwxRRAQ+jf2tqVb/Ly7z6JYvkrOKIOv5rbXYQoiYWkr4+XxGt5UeRZ7Z2pP4maYwqi7JY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585560324; 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=EjfKGh+YzvyI9KcgsZDJ/n+MtrJUjkPmcPnCTX+o+nA=; b=TxpRawCQ8i6x4maQ2AOJX83q3Vc18pa7pxTVaRZClg5nICix0wwDXaU5Q5ed9loz6Ov+mgRRyPmvYSaOLFnDxrH+n+i+mwouzgifEl9N18+y56wTiQZI/ad2mDl+1gexhHnQx5T2z2sBpEXVlGNYrFoLX92p2hp1r8ohHbTW2rg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [216.205.24.74]) by mx.zohomail.com with SMTPS id 1585560324088824.3332711874765; Mon, 30 Mar 2020 02:25:24 -0700 (PDT) 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-49-LAJNmDesMiWDVRJC8n0gaA-1; Mon, 30 Mar 2020 05:25:20 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F3F9D13FC; Mon, 30 Mar 2020 09:25:13 +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 BBA2A97AE3; Mon, 30 Mar 2020 09:25:13 +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 7143C944CD; Mon, 30 Mar 2020 09:25:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02U9P9ig004074 for ; Mon, 30 Mar 2020 05:25:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 47182D767B; Mon, 30 Mar 2020 09:25:09 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id B82E6D7678 for ; Mon, 30 Mar 2020 09:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585560322; 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=EjfKGh+YzvyI9KcgsZDJ/n+MtrJUjkPmcPnCTX+o+nA=; b=dSCD/7YrMKWKrsczwpoDToVik1vptTSl99iAIJR1Tu8a4MV6mR24aCw9yRMt+4v31AVOHq 2ZPidzMMJaYjRAsCIFqAyCgPi625h6vElsGoQES9BLy6q0g40yyvkBFM3zbcNfM+3oy3Zf tgS1OL01Xtm1YZLadY4JgryVySTtlYQ= X-MC-Unique: LAJNmDesMiWDVRJC8n0gaA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/3] virQEMUCapsNewBinary: Avoid NULL dereference Date: Mon, 30 Mar 2020 11:24:59 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.13 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" Even with GLib it is still possible for virQEMUCapsNew() to return NULL because it calls virQEMUCapsInitialize() which is a wrapper over pthread_once() which may fail. At least, we still check for its retval. If it so happens that the virQEMUCapsNew() fails and returns NULL, we should not dereference it. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_capabilities.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index a95a60c36a..3afe8a7b2c 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -1713,7 +1713,8 @@ virQEMUCapsNewBinary(const char *binary) { virQEMUCapsPtr qemuCaps =3D virQEMUCapsNew(); =20 - qemuCaps->binary =3D g_strdup(binary); + if (qemuCaps) + qemuCaps->binary =3D g_strdup(binary); =20 return qemuCaps; } --=20 2.24.1 From nobody Sat May 4 06:32:56 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.74 as permitted sender) client-ip=63.128.21.74; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-74.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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=1585560336; cv=none; d=zohomail.com; s=zohoarc; b=WNGRSRXuQ2lnCFeMT0hcbtTP8z1HqjBZSfbTh3KLn/vHsUZCz1PyJSeFF+qGPyABUhjfDr/QyhbD0yTW5/lTCF2Ww9b1H50yBbI3ZXeNuFmmHXHHR5atgBPCzePm4t9K8BYMls7xnolxqjAk06y+XQXWAkEbsF0jWfynNMhk9zo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585560336; 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=rjtojpPwmk3Wbu5kEbfqdWCkZXPZ89LTD7VlDTFlCQ8=; b=jPVpTSXsQlj38JwlZYUsezq0LYTD9jBoRawTxGqmnyxdlaEWkXW1woH8GrHbfvOBw2WkhpZtz/qD+N6ejHhzD2SlIOoV/vhudxXnd9UlnuTp9pqMIl9+jUTM6VIXve223lqWgn965GUqX54fQfLo4rz3s6KS7PYHq/DU9kk/CKI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.74 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-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) by mx.zohomail.com with SMTPS id 1585560336261464.49631890891567; Mon, 30 Mar 2020 02:25:36 -0700 (PDT) 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-16-vv-5R1WdNx-xyuFypZ0wKw-1; Mon, 30 Mar 2020 05:25:32 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2224118A5500; Mon, 30 Mar 2020 09:25:27 +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 E9FA360BE2; Mon, 30 Mar 2020 09:25:26 +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 9BCB5944D6; Mon, 30 Mar 2020 09:25:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 02U9PAei004082 for ; Mon, 30 Mar 2020 05:25:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2BC08D767B; Mon, 30 Mar 2020 09:25:10 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.215]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C7CED7678 for ; Mon, 30 Mar 2020 09:25:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585560335; 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=rjtojpPwmk3Wbu5kEbfqdWCkZXPZ89LTD7VlDTFlCQ8=; b=YB5QYTwMirGc+dPHDr0f/88AMtcAaoF1cljnttZMXBtfFF00mWP3vBxLEJ6882iUO4utjK RMPH8Mq/B/nBw5LpM1YhJlmWrqe0MWXbiE1LQkFdjVv5NHepqp0gAqu08QLjN7gUz+gu7e 0EW44xxWjKKAWQ7KSjEI1FRYGeV6WQw= X-MC-Unique: vv-5R1WdNx-xyuFypZ0wKw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/3] virSecurityDeviceLabelDefNew: Avoid NULL dereference Date: Mon, 30 Mar 2020 11:25:00 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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.79 on 10.5.11.12 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" While it is impossible for VIR_ALLOC() to return an error, we should be consistent with the rest of the code and not continue initializing the virSecurityDeviceLabelDef structure. Signed-off-by: Michal Privoznik Reviewed-by: Daniel P. Berrang=C3=A9 --- src/util/virseclabel.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/virseclabel.c b/src/util/virseclabel.c index a2b5ebf6b7..2141d84210 100644 --- a/src/util/virseclabel.c +++ b/src/util/virseclabel.c @@ -77,7 +77,7 @@ virSecurityDeviceLabelDefNew(const char *model) =20 if (VIR_ALLOC(seclabel) < 0) { virSecurityDeviceLabelDefFree(seclabel); - seclabel =3D NULL; + return NULL; } =20 seclabel->model =3D g_strdup(model); --=20 2.24.1