From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982154443752.8145747772014; Tue, 17 Apr 2018 09:22:34 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id D7C2331524D8; Tue, 17 Apr 2018 16:22:32 +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 A234819808; Tue, 17 Apr 2018 16:22:32 +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 4DECC4CA9E; Tue, 17 Apr 2018 16:22:32 +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 w3HGMUsC001713 for ; Tue, 17 Apr 2018 12:22:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id A792A19E1F; Tue, 17 Apr 2018 16:22:30 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 692E419E37 for ; Tue, 17 Apr 2018 16:22:25 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:12 -0400 Message-Id: <20180417162218.14378-2-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] conf: Add error checking to virDomainSnapshotDiskDefFormat 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Tue, 17 Apr 2018 16:22:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Commit id '43f2ccdc' called virDomainDiskSourceDefFormatInternal rather than formatting the the disk source inline. However, it did not handle the case where the helper failed. Over time the helper has been renamed to virDomainDiskSourceFormat. Similar to other consumers, if virDomainDiskSourceFormat fails, then the formatting could be off, so it's better to fail than to continue on with some possibly bad data. Alter the function and the caller to check status and jump to error in that case. Found by Coverity Signed-off-by: John Ferlan --- src/conf/snapshot_conf.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/conf/snapshot_conf.c b/src/conf/snapshot_conf.c index d7b086242b..787c3d0feb 100644 --- a/src/conf/snapshot_conf.c +++ b/src/conf/snapshot_conf.c @@ -662,7 +662,7 @@ virDomainSnapshotAlignDisks(virDomainSnapshotDefPtr def, return ret; } =20 -static void +static int virDomainSnapshotDiskDefFormat(virBufferPtr buf, virDomainSnapshotDiskDefPtr disk, virDomainXMLOptionPtr xmlopt) @@ -670,7 +670,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, int type =3D disk->src->type; =20 if (!disk->name) - return; + return 0; =20 virBufferEscapeString(buf, "name); if (disk->snapshot > 0) @@ -679,7 +679,7 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, =20 if (!disk->src->path && disk->src->format =3D=3D 0) { virBufferAddLit(buf, "/>\n"); - return; + return 0; } =20 virBufferAsprintf(buf, " type=3D'%s'>\n", virStorageTypeToString(type)= ); @@ -688,10 +688,12 @@ virDomainSnapshotDiskDefFormat(virBufferPtr buf, if (disk->src->format > 0) virBufferEscapeString(buf, "\n", virStorageFileFormatTypeToString(disk->src->= format)); - virDomainDiskSourceFormat(buf, disk->src, 0, 0, xmlopt); + if (virDomainDiskSourceFormat(buf, disk->src, 0, 0, xmlopt) < 0) + return -1; =20 virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n"); + return 0; } =20 =20 @@ -741,8 +743,10 @@ virDomainSnapshotDefFormat(const char *domain_uuid, if (def->ndisks) { virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); - for (i =3D 0; i < def->ndisks; i++) - virDomainSnapshotDiskDefFormat(&buf, &def->disks[i], xmlopt); + for (i =3D 0; i < def->ndisks; i++) { + if (virDomainSnapshotDiskDefFormat(&buf, &def->disks[i], xmlop= t) < 0) + goto error; + } virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982166165422.71220110081856; Tue, 17 Apr 2018 09:22:46 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5E8C680472; Tue, 17 Apr 2018 16:22:44 +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 28EDE18033; Tue, 17 Apr 2018 16:22:44 +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 D2A3D4CAA7; Tue, 17 Apr 2018 16:22:43 +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 w3HGMgoE001748 for ; Tue, 17 Apr 2018 12:22:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id F212F6920A; Tue, 17 Apr 2018 16:22:42 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A9E2A19E83 for ; Tue, 17 Apr 2018 16:22:30 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:13 -0400 Message-Id: <20180417162218.14378-3-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] remote: Fix usage of ATTRIBUTE_FALLTHROUGH 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 17 Apr 2018 16:22:45 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Move to within the #if since the #else portion ends with a goto and that raised concern by Coverity. Signed-off-by: John Ferlan --- src/remote/remote_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d3b588c374..12f7d47388 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -928,6 +928,7 @@ doRemoteOpen(virConnectPtr conn, if (!priv->tls) goto failed; priv->is_secure =3D 1; + ATTRIBUTE_FALLTHROUGH; #else (void)tls_priority; (void)sanity; @@ -937,7 +938,6 @@ doRemoteOpen(virConnectPtr conn, goto failed; #endif =20 - ATTRIBUTE_FALLTHROUGH; case trans_tcp: priv->client =3D virNetClientNewTCP(priv->hostname, port, AF_UNSPE= C); if (!priv->client) --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982181006234.678030373095; Tue, 17 Apr 2018 09:23:01 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id A66FD4ACA7; Tue, 17 Apr 2018 16:22:59 +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 6E8C519E37; Tue, 17 Apr 2018 16:22:59 +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 1F06D180215F; Tue, 17 Apr 2018 16:22:59 +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 w3HGMwk6001785 for ; Tue, 17 Apr 2018 12:22:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id 38E5119E1F; Tue, 17 Apr 2018 16:22:58 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id EED8019E31 for ; Tue, 17 Apr 2018 16:22:43 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:14 -0400 Message-Id: <20180417162218.14378-4-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] tests: Return failure if log not fopen'd 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 17 Apr 2018 16:23:00 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If @log is not fopen'd then, going to cleanup and calling fclose will make for an unhappy caller. So just fail immediately instead since there's nothing to clean up. Found by Coverity Signed-off-by: John Ferlan --- tests/commandhelper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 1da2834aa4..bf91550ede 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -67,7 +67,7 @@ int main(int argc, char **argv) { int ret =3D EXIT_FAILURE; =20 if (!log) - goto cleanup; + return ret; =20 for (i =3D 1; i < argc; i++) fprintf(log, "ARG:%s\n", argv[i]); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982199236396.1311828361796; Tue, 17 Apr 2018 09:23:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DE25861470; Tue, 17 Apr 2018 16:23:16 +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 E9E3839BA; Tue, 17 Apr 2018 16:23: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 3F0D54CA9F; Tue, 17 Apr 2018 16:23:15 +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 w3HGNDoc001856 for ; Tue, 17 Apr 2018 12:23:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7B65019E8C; Tue, 17 Apr 2018 16:23:13 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D14C65B6C for ; Tue, 17 Apr 2018 16:22:58 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:15 -0400 Message-Id: <20180417162218.14378-5-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] tests: Don't call virNetServerClientClose without valid client 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 17 Apr 2018 16:23:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If @client hasn't been opened, then don't call virNetServerClientClose since that'll cause certain failure. Found by Coverity Signed-off-by: John Ferlan --- tests/virnetserverclienttest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/virnetserverclienttest.c b/tests/virnetserverclienttest.c index 398b46928c..aa3f0bcf9b 100644 --- a/tests/virnetserverclienttest.c +++ b/tests/virnetserverclienttest.c @@ -152,7 +152,8 @@ static int testIdentity(const void *opaque ATTRIBUTE_UN= USED) ret =3D 0; cleanup: virObjectUnref(sock); - virNetServerClientClose(client); + if (!client) + virNetServerClientClose(client); virObjectUnref(client); virObjectUnref(ident); VIR_FORCE_CLOSE(sv[0]); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982202596769.4726661456623; Tue, 17 Apr 2018 09:23:22 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4E9853132585; Tue, 17 Apr 2018 16:23:21 +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 22D457ED46; Tue, 17 Apr 2018 16:23:21 +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 10BB84CAAC; Tue, 17 Apr 2018 16:23:20 +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 w3HGND1A001862 for ; Tue, 17 Apr 2018 12:23:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id E12A919E8C; Tue, 17 Apr 2018 16:23:13 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id A2DDC19E8F for ; Tue, 17 Apr 2018 16:23:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:16 -0400 Message-Id: <20180417162218.14378-6-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] tests: Add checks for possible errors 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Tue, 17 Apr 2018 16:23:21 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If virJSONValueObjectGetArray fails to find "members" in @localroot, then using @rootmembers in subsequent calls which assume that it was successful will not go well. So add a check that it was successfully fetched and an error if not. Similarly virJSONValueArraySize returns an 'ssize_t', so the callers should use the right type and they should check the return value against -1 and print an error if something is wrong. Found by Coverity Signed-off-by: John Ferlan --- tests/testutilsqemuschema.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/testutilsqemuschema.c b/tests/testutilsqemuschema.c index 21f5d119e8..79c526ac7c 100644 --- a/tests/testutilsqemuschema.c +++ b/tests/testutilsqemuschema.c @@ -97,14 +97,19 @@ struct testQEMUSchemaValidateObjectMemberData { =20 static virJSONValuePtr testQEMUSchemaStealObjectMemberByName(const char *name, - virJSONValuePtr members) + virJSONValuePtr members, + virBufferPtr debug) { virJSONValuePtr member; virJSONValuePtr ret =3D NULL; - size_t n; + ssize_t n; size_t i; =20 - n =3D virJSONValueArraySize(members); + if ((n =3D virJSONValueArraySize(members)) < 0) { + virBufferAddLit(debug, "ERROR: members size < 0"); + return NULL; + } + for (i =3D 0; i < n; i++) { member =3D virJSONValueArrayGet(members, i); =20 @@ -132,7 +137,7 @@ testQEMUSchemaValidateObjectMember(const char *key, virBufferStrcat(data->debug, key, ": ", NULL); =20 /* lookup 'member' entry for key */ - if (!(keymember =3D testQEMUSchemaStealObjectMemberByName(key, data->r= ootmembers))) { + if (!(keymember =3D testQEMUSchemaStealObjectMemberByName(key, data->r= ootmembers, data->debug))) { virBufferAddLit(data->debug, "ERROR: attribute not in schema"); goto cleanup; } @@ -188,7 +193,7 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValuePt= r root, virHashTablePtr schema, virBufferPtr debug) { - size_t n; + ssize_t n; size_t i; virJSONValuePtr variants =3D NULL; virJSONValuePtr variant; @@ -203,7 +208,11 @@ testQEMUSchemaValidateObjectMergeVariant(virJSONValueP= tr root, return -2; } =20 - n =3D virJSONValueArraySize(variants); + if ((n =3D virJSONValueArraySize(variants)) < 0) { + virBufferAddLit(debug, "ERROR: 'variants' array size < 0"); + return -2; + } + for (i =3D 0; i < n; i++) { variant =3D virJSONValueArrayGet(variants, i); =20 @@ -307,7 +316,10 @@ testQEMUSchemaValidateObject(virJSONValuePtr obj, =20 =20 /* validate members */ - data.rootmembers =3D virJSONValueObjectGetArray(localroot, "members"); + if (!(data.rootmembers =3D virJSONValueObjectGetArray(localroot, "memb= ers"))) { + virBufferAddLit(debug, "ERROR: missing attribute 'members'\n"); + goto cleanup; + } if (virJSONValueObjectForeachKeyValue(obj, testQEMUSchemaValidateObjectMemb= er, &data) < 0) @@ -342,7 +354,7 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj, const char *objstr; virJSONValuePtr values =3D NULL; virJSONValuePtr value; - size_t n; + ssize_t n; size_t i; =20 if (virJSONValueGetType(obj) !=3D VIR_JSON_TYPE_STRING) { @@ -358,7 +370,10 @@ testQEMUSchemaValidateEnum(virJSONValuePtr obj, return -2; } =20 - n =3D virJSONValueArraySize(values); + if ((n =3D virJSONValueArraySize(values)) < 0) { + virBufferAddLit(debug, "ERROR: enum values array size < 0"); + return -2; + } for (i =3D 0; i < n; i++) { value =3D virJSONValueArrayGet(values, i); =20 @@ -423,7 +438,7 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj, { virJSONValuePtr members; virJSONValuePtr member; - size_t n; + ssize_t n; size_t i; const char *membertype; virJSONValuePtr memberschema; @@ -439,7 +454,10 @@ testQEMUSchemaValidateAlternate(virJSONValuePtr obj, virBufferAdjustIndent(debug, 3); indent =3D virBufferGetIndent(debug, false); =20 - n =3D virJSONValueArraySize(members); + if ((n =3D virJSONValueArraySize(members)) < 0) { + virBufferAddLit(debug, "ERROR: alternate schema 'members' array si= ze < 0"); + return -2; + } for (i =3D 0; i < n; i++) { membertype =3D NULL; =20 --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982211916362.02481720766866; Tue, 17 Apr 2018 09:23:31 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B45E981DE4; Tue, 17 Apr 2018 16:23: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 7D2821822F; Tue, 17 Apr 2018 16:23: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 335E64CAAB; Tue, 17 Apr 2018 16:23:30 +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 w3HGNSFK001916 for ; Tue, 17 Apr 2018 12:23:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6D640D1F8; Tue, 17 Apr 2018 16:23:28 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2FE9867F16 for ; Tue, 17 Apr 2018 16:23:13 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:17 -0400 Message-Id: <20180417162218.14378-7-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] qemu: Fix possible memory leak in migration param processing 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 17 Apr 2018 16:23:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If virJSONValueArraySize(caps) <=3D 0, then we will still need to virJSONValueFree(caps) because qemuMonitorSetMigrationCapabilities won't consume it. Found by Coverity Signed-off-by: John Ferlan --- src/qemu/qemu_migration_params.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 4f3b239637..3bbe50a8ed 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -771,6 +771,7 @@ qemuMigrationParamsApply(virQEMUDriverPtr driver, migParams->params[xbzrle].set =3D true; =20 virJSONValueFree(params); + virJSONValueFree(caps); =20 return ret; } --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 04:35:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1523982224880413.0050585591041; Tue, 17 Apr 2018 09:23:44 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 59B84C03D469; Tue, 17 Apr 2018 16:23:43 +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 2D6AE19808; Tue, 17 Apr 2018 16:23:43 +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 E013E180005A; Tue, 17 Apr 2018 16:23:42 +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 w3HGNf1g001951 for ; Tue, 17 Apr 2018 12:23:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id D0ABB9060; Tue, 17 Apr 2018 16:23:40 +0000 (UTC) Received: from unknown54ee7586bd10.attlocal.net.com (ovpn-116-30.phx2.redhat.com [10.3.116.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91B8469C84 for ; Tue, 17 Apr 2018 16:23:28 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 17 Apr 2018 12:22:18 -0400 Message-Id: <20180417162218.14378-8-jferlan@redhat.com> In-Reply-To: <20180417162218.14378-1-jferlan@redhat.com> References: <20180417162218.14378-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] qemu: Check for missing 'return' in qemuMonitorJSONCheckReply 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 17 Apr 2018 16:23:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" If the "return" is not in the reply, then the subsequent virJSONValueGetType will not be happy. Found by Coverity Signed-off-by: John Ferlan --- src/qemu/qemu_monitor_json.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 410fa178b2..681c0575c3 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -423,7 +423,12 @@ qemuMonitorJSONCheckReply(virJSONValuePtr cmd, if (qemuMonitorJSONCheckError(cmd, reply) < 0) return -1; =20 - data =3D virJSONValueObjectGet(reply, "return"); + if (!(data =3D virJSONValueObjectGet(reply, "return"))) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'return' for returned data")); + return -1; + } + if (virJSONValueGetType(data) !=3D type) { char *cmdstr =3D virJSONValueToString(cmd, false); char *retstr =3D virJSONValueToString(data, false); --=20 2.13.6 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list