From nobody Tue Nov 26 11:55:12 2024 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=1574326739; cv=none; d=zoho.com; s=zohoarc; b=md/ydmlbKjCB9AdCkTIh67EURYf53Kzz8dYH4H87RhDrnb8i8l72huYCNg9lb1Kp5UVf9YRctlbi4WBcVEz7c5JgjiHOs33Xb7EGvk64nKwut85Vz6lW+v+ePcipGOQMflR15nOcTlU+KVmxNq1nFug4ZLqQDN6nWx9OIXHQUug= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574326739; h=Content-Type:Content-Transfer-Encoding:Cc: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=30qtHfJKSEWBJ07alAFhzKpPJnr2yruwcz62jcF8xTY=; b=cFxn74hMhlWwYVwOnaRQL0q2jJttJkhYmt23G7ci1tZoe5I8hE7H7gVGo7ADNtGH/LnItIfYzJfs4B2z8FDJH1bnBWdRdEK7nnhENrVxaWiEM2aGmL6Crq5zDErGWwPaXzRxOUB/KFjFXHKaWBSt5gfuXToJ+9gflHGhZR4TZLU= 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 1574326739441607.1468808517433; Thu, 21 Nov 2019 00:58:59 -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-385-iy2Fawz_M8ybYz9L-JXDng-1; Thu, 21 Nov 2019 03:58:56 -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 054BF18557CE; Thu, 21 Nov 2019 08:58:51 +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 D50A11073034; Thu, 21 Nov 2019 08:58:50 +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 8C3AF4E566; Thu, 21 Nov 2019 08:58:50 +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 xAL8waBF000694 for ; Thu, 21 Nov 2019 03:58:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id D4AEB53E19; Thu, 21 Nov 2019 08:58:36 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3514860BC3; Thu, 21 Nov 2019 08:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574326738; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=30qtHfJKSEWBJ07alAFhzKpPJnr2yruwcz62jcF8xTY=; b=DVGDkV3BxSeMhBzE0ehnyPOTmm7LfnQ7Chvgq/IIkCjZfLDQY4rsgRFKjg+0yOWRFBeFnr eeuRAATA99wOHVibOCmyJ0qhONSZkV7ximx/vtO3giiKeI7kz1HLqf3rnCTVhlP5EVds1k d2gErfJuvIvditQr9q5lPUIYUUw951U= From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 21 Nov 2019 09:58:29 +0100 Message-Id: <278b16e1f923283316c224133a9f11c8a2468a3a.1574326693.git.eskultet@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 Cc: Erik Skultety Subject: [libvirt] [PATCH v2 1/4] rpc: gendispatch: Fix a couple of places adding trailing spaces 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 X-MC-Unique: iy2Fawz_M8ybYz9L-JXDng-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" Signed-off-by: Erik Skultety Reviewed-by: Daniel P. Berrang=C3=A9 --- src/rpc/gendispatch.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 7c868191d1..8656c8f205 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1062,7 +1062,7 @@ elsif ($mode eq "server") { print "\n"; =20 print " $conn_type $conn_var =3D $conn_method(client);\n"; - print " if (!$conn_var) \n"; + print " if (!$conn_var)\n"; print " goto cleanup;\n"; print "\n"; =20 @@ -1144,7 +1144,7 @@ elsif ($mode eq "server") { print "\n"; } else { if ($modern_ret_as_list) { - print " if ((nresults =3D \n"; + print " if ((nresults =3D\n"; my $indln =3D " $prefix$call->{ProcName}("; print $indln; print join(",\n" . ' ' x (length $indln), @args_list); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Nov 26 11:55:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1574326731; cv=none; d=zoho.com; s=zohoarc; b=F2MGHyGnIIBVa0ENYHBwZeBnhRSTyf/v/8qdg2GM3aH3tFI+S1QvsR4hU2lUu+l+h48eFv9sxQGe6+h/End/GSObv2B7Lh7v4z6NcdEVACKLAonz63RRb7hCxBo3iVIqA3BZHCTOXyrjipdxKq6ROuuI2ecO+pXmKFGCkEXkUTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574326731; h=Content-Type:Content-Transfer-Encoding:Cc: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=xU29Q3yL5SRtch1+8V0V0y4agEGDA4dZT/utpm8ZJrk=; b=D4b/LhJ+e0vSCgrCmNSBcZ1SBBeg/zC8KjiP20bNO+M5L6Szi+R8pH0MEC8GjQDrMQ6kxsru9i9iSvc1bJTVNrygntKbDaLq+d+PJGATOEaOZXlTDmDb9Gw8+RX73z6MLyvXouyqCRwppoT3OSYE/rhgAAPuBTD3WTdjlZZl4lc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 157432673103570.5348195383076; Thu, 21 Nov 2019 00:58:51 -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-407-2etbBiMXPfyPpgBUrjYbWA-1; Thu, 21 Nov 2019 03:58:47 -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 8DE361034AE4; Thu, 21 Nov 2019 08:58:41 +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 145F060BC3; Thu, 21 Nov 2019 08:58:41 +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 A26121809567; Thu, 21 Nov 2019 08:58:39 +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 xAL8wbMM000702 for ; Thu, 21 Nov 2019 03:58:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id CD68853E19; Thu, 21 Nov 2019 08:58:37 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D69A60BC3; Thu, 21 Nov 2019 08:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574326729; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=xU29Q3yL5SRtch1+8V0V0y4agEGDA4dZT/utpm8ZJrk=; b=VzSz5NN6Y/qqy5S978nutjES71+3WeOxYsecC4KnZ5GMAOh2miY5C45chG3dspMcnPvONl xffGVlK/CEZoDattBo7+8KjNHICF3mnFxwuHzCcjxJfrMQAtHQRF4EC0nl4qEi+5eXPJVS hTFE+8cclyY+LuzhySsvRrbabgMEWdE= From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 21 Nov 2019 09:58:30 +0100 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 Cc: Erik Skultety Subject: [libvirt] [PATCH v2 2/4] rpc: gendispatch: Add a check for zero size client-side buffers 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: 2etbBiMXPfyPpgBUrjYbWA-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" After libvirt switched to GLib, we also started to use glib allocation primitives as of commit e85e34f3. Unlike malloc which is ambiguous with regards to size =3D=3D 0 (which in our case returned a unique pointer safe to be passed to free), g_malloc0 strictly returns NULL on size =3D=3D 0. This change broke our legacy APIs which rely on the caller to pre-allocate the target buffer to hold the results and pass the buffer size as an argument. Since it makes very little sense to call an API with nowhere to store the results, fix this by returning 0 directly in such case in the RPC dispatch code - there are modern API equivalents allocating the target buffer automatically anyway. https://bugzilla.redhat.com/show_bug.cgi?id=3D1772842 Signed-off-by: Erik Skultety --- src/rpc/gendispatch.pl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl index 8656c8f205..524d31f741 100755 --- a/src/rpc/gendispatch.pl +++ b/src/rpc/gendispatch.pl @@ -1073,6 +1073,14 @@ elsif ($mode eq "server") { print " goto cleanup;\n"; print " }\n"; print "\n"; + + + print " if (args->$single_ret_list_max_var =3D=3D 0) {\n"; + print " ret->$single_ret_list_name.${single_ret_list_na= me}_len =3D 0;\n"; + print " rv =3D 0;\n"; + print " goto cleanup;\n"; + print " }\n"; + print "\n"; } =20 print join("\n", @getters_list); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Nov 26 11:55:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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=1574326738; cv=none; d=zoho.com; s=zohoarc; b=gHarlunv25OXQYy+0Ftzu6VlC2v3DPMDNNxupc0xI0/Q5OUG/WJMCFpoJHy0D30xC/PJeG4cgkf/R7wcL3bh71tTX0tNbamqdwF/Nf00fG3gJPprXOZckGmIGSXOYVKPHO/SuPhQG/Qk5qjwyUT5aIK7/NYJxhGlLD9kc25OJfk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574326738; h=Content-Type:Content-Transfer-Encoding:Cc: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=UGG+aKl9jPsZqFz0koyT8D8xPO3hpkvlOq4gXxyZknU=; b=ogM1DC30CnghcDx7pS3461hSyGj6qZ4fB45VU++GKei/J7RwBWzJcKE88t4oKG4bBt+yQK/NJ5pnPqfbNSsVjAjykcIFUAoFkKA/rkydIUOXWfEEdGtsBWiL+YrRjwb/pWrnWgtXsAPzukrgIetc6Kwj6KSAj7HEXRK3R60Buew= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1574326738923745.3609933525793; Thu, 21 Nov 2019 00:58:58 -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-270-lqjRDxvMNNCc3lgaGjTn4g-1; Thu, 21 Nov 2019 03:58:55 -0500 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 02AAEDBF6; Thu, 21 Nov 2019 08:58:51 +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 CBA2F4139; Thu, 21 Nov 2019 08:58:50 +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 801BC4E562; Thu, 21 Nov 2019 08:58:50 +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 xAL8wcFN000710 for ; Thu, 21 Nov 2019 03:58:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id C8DE153E1D; Thu, 21 Nov 2019 08:58:38 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272BD53E19; Thu, 21 Nov 2019 08:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574326737; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=UGG+aKl9jPsZqFz0koyT8D8xPO3hpkvlOq4gXxyZknU=; b=UIo4cwE8qJtQ4JbcuSt7OF2TYvJ70OQlUdng1FqfVjgZrminJLjsTa7Vi0L1n3t+W2ImY/ RBG5xX5PWuYOW/PDwAha+kkF+oUPOa5fpj+2Z6I38wqxRvzbUyxHlVf0fCCDiY3aatYBXV CI7cXs9yIBmej7XgDhAHrcK7rtTxDIU= From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 21 Nov 2019 09:58:31 +0100 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 Cc: Erik Skultety Subject: [libvirt] [PATCH v2 3/4] remote: Add a check for zero sized client-side buffers 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-MC-Unique: lqjRDxvMNNCc3lgaGjTn4g-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" Adjustment to the dispatch code which is not generated by gendispatch.pl. Signed-off-by: Erik Skultety --- src/remote/remote_daemon_dispatch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon= _dispatch.c index f369ffb02a..1d75ec3d37 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -2753,6 +2753,12 @@ remoteDispatchDomainGetVcpuPinInfo(virNetServerPtr s= erver G_GNUC_UNUSED, goto cleanup; } =20 + if (args->ncpumaps =3D=3D 0) { + ret->cpumaps.cpumaps_len =3D 0; + rv =3D 0; + goto cleanup; + } + if (INT_MULTIPLY_OVERFLOW(args->ncpumaps, args->maplen) || args->ncpumaps * args->maplen > REMOTE_CPUMAPS_MAX) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("maxinfo * maplen >= REMOTE_CPUMAPS_MAX")); --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Nov 26 11:55:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.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 205.139.110.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=1574326733; cv=none; d=zoho.com; s=zohoarc; b=c1RvrWiPYyPYYPcrOq6K6kSlY+mt9POsU0h0iHaQ8hiI6le3wLcMdpKQjnQcwb2tlIU8qC1vDzyNExeY5UVnlEehChAbTpffYGOweENAN/eWgO2ABAmOYqBuK44j6FNKYF7JMR5ZOdbc4OW3hy/LC4m6GoL0ir/NakBiHFPhnj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1574326733; h=Content-Type:Content-Transfer-Encoding:Cc: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=tQKn5uSf5mpCMhBiKw8Qp9IWPmlVNuRSQBR7dg2qL7A=; b=XOx+rUzg+In1ABea8N2IWCybJlFB/V3ywSUs3gs+00xpjc1pRVjE35skDx9YmjkFiougt1R4FxS6Gxb9S7Cj38S+nqT5asaQejPfJGPq7ksjF+W+r5/Zg4xZ41LqCyBhhYxuwhG2SfCLmDiC2PJQZaFn3a9wvfQMzX3aYLdD8mo= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.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 [205.139.110.120]) by mx.zohomail.com with SMTPS id 1574326733118356.7266753989096; Thu, 21 Nov 2019 00:58:53 -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-42-iBM3HZdlNyWwui9-U7k59Q-1; Thu, 21 Nov 2019 03:58:47 -0500 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 91372100551B; Thu, 21 Nov 2019 08:58:42 +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 6889B6FDD9; Thu, 21 Nov 2019 08:58:42 +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 2568118089CE; Thu, 21 Nov 2019 08:58: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 xAL8wdjs000718 for ; Thu, 21 Nov 2019 03:58:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id C2F0D53E19; Thu, 21 Nov 2019 08:58:39 +0000 (UTC) Received: from ridgehead.redhat.com (unknown [10.43.2.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2279E60BC3; Thu, 21 Nov 2019 08:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574326731; h=from:from:sender:sender: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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tQKn5uSf5mpCMhBiKw8Qp9IWPmlVNuRSQBR7dg2qL7A=; b=ED1OV3fIPWsO8lWjzCHk9DaGl834i+dQJWvKqHbQ/gyE4uvJGSHROoF2G2/XARK21GYnGk A7w9uafqqU+eV0BBy/XZnouU+RerqZz5fB/JRFPyAdIZ9Bnu2V8fUURC9BZu8cj4iIHgC1 yC4WEPg6OCRwjcTEzi9wjZeEqkz24yU= From: Erik Skultety To: libvir-list@redhat.com Date: Thu, 21 Nov 2019 09:58:32 +0100 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 Cc: Erik Skultety Subject: [libvirt] [PATCH v2 4/4] libvirt-: Check caller-provided buffers to be NULL with size > 0 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-MC-Unique: iBM3HZdlNyWwui9-U7k59Q-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" Pre-Glib era which used malloc allowed the size of the client-side buffers to be declared as 0, because malloc documents that it can either return 0 or a unique pointer on 0 size allocations. With glib this doesn't work anymore, because glib documents that for such allocation requests NULL is always returned which results in an error in our public API checks server-side. This patch complements the fix in the RPC layer by explicitly erroring out on the following combination of args used by our legacy APIs (their moder equivalents don't suffer from this): function(caller-allocated-array, size, ...) { if (!caller-allocated-array && size > 0) return error; } treating everything else as a valid input and potentially let that fail on the server-side rather than client-side. Signed-off-by: Erik Skultety Reviewed-by: Daniel P. Berrang=C3=A9 --- src/internal.h | 13 +++++++++++++ src/libvirt-domain-snapshot.c | 4 ++-- src/libvirt-domain.c | 21 ++++++--------------- src/libvirt-host.c | 2 +- src/libvirt-interface.c | 4 ++-- src/libvirt-network.c | 4 ++-- src/libvirt-nodedev.c | 4 ++-- src/libvirt-nwfilter.c | 2 +- src/libvirt-secret.c | 2 +- src/libvirt-storage.c | 6 +++--- 10 files changed, 33 insertions(+), 29 deletions(-) diff --git a/src/internal.h b/src/internal.h index 0ff9f496ac..bcc5a1c157 100644 --- a/src/internal.h +++ b/src/internal.h @@ -429,6 +429,19 @@ } \ } while (0) =20 +/* This check is intended to be used with legacy APIs only which expect the + * caller to pre-allocate the target buffer. + * We want to allow callers pass NULL arrays if the size is declared as 0 = and + * still succeed in calling the API. + */ +#define virCheckNonNullArrayArgGoto(argname, argsize, label) \ + do { \ + if (!argname && argsize > 0) { \ + virReportInvalidNonNullArg(argname); \ + goto label; \ + } \ + } while (0) + =20 /* Count leading zeros in an unsigned int. * diff --git a/src/libvirt-domain-snapshot.c b/src/libvirt-domain-snapshot.c index 20a3bc5545..33593e11e9 100644 --- a/src/libvirt-domain-snapshot.c +++ b/src/libvirt-domain-snapshot.c @@ -398,7 +398,7 @@ virDomainSnapshotListNames(virDomainPtr domain, char **= names, int nameslen, virCheckDomainReturn(domain, -1); conn =3D domain->conn; =20 - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, nameslen, error); virCheckNonNegativeArgGoto(nameslen, error); =20 if (conn->driver->domainSnapshotListNames) { @@ -600,7 +600,7 @@ virDomainSnapshotListChildrenNames(virDomainSnapshotPtr= snapshot, virCheckDomainSnapshotReturn(snapshot, -1); conn =3D snapshot->domain->conn; =20 - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, nameslen, error); virCheckNonNegativeArgGoto(nameslen, error); =20 if (conn->driver->domainSnapshotListChildrenNames) { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 02622cb2ca..17cdd5bcaf 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -59,7 +59,7 @@ virConnectListDomains(virConnectPtr conn, int *ids, int m= axids) virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(ids, error); + virCheckNonNullArrayArgGoto(ids, maxids, error); virCheckNonNegativeArgGoto(maxids, error); =20 if (conn->driver->connectListDomains) { @@ -6386,7 +6386,7 @@ virConnectListDefinedDomains(virConnectPtr conn, char= **const names, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->driver->connectListDefinedDomains) { @@ -7298,7 +7298,7 @@ virDomainGetVcpuPinInfo(virDomainPtr domain, int ncpu= maps, virCheckDomainReturn(domain, -1); conn =3D domain->conn; =20 - virCheckNonNullArgGoto(cpumaps, error); + virCheckNonNullArrayArgGoto(cpumaps, ncpumaps, error); virCheckPositiveArgGoto(ncpumaps, error); virCheckPositiveArgGoto(maplen, error); =20 @@ -10996,10 +10996,7 @@ virDomainGetDiskErrors(virDomainPtr dom, =20 virCheckDomainReturn(dom, -1); =20 - if (maxerrors) - virCheckNonNullArgGoto(errors, error); - else - virCheckNullArgGoto(errors, error); + virCheckNonNullArrayArgGoto(errors, maxerrors, error); =20 if (dom->conn->driver->domainGetDiskErrors) { int ret =3D dom->conn->driver->domainGetDiskErrors(dom, errors, @@ -11136,10 +11133,7 @@ virDomainFSFreeze(virDomainPtr dom, =20 virCheckDomainReturn(dom, -1); virCheckReadOnlyGoto(dom->conn->flags, error); - if (nmountpoints) - virCheckNonNullArgGoto(mountpoints, error); - else - virCheckNullArgGoto(mountpoints, error); + virCheckNonNullArrayArgGoto(mountpoints, nmountpoints, error); =20 if (dom->conn->driver->domainFSFreeze) { int ret =3D dom->conn->driver->domainFSFreeze( @@ -11181,10 +11175,7 @@ virDomainFSThaw(virDomainPtr dom, =20 virCheckDomainReturn(dom, -1); virCheckReadOnlyGoto(dom->conn->flags, error); - if (nmountpoints) - virCheckNonNullArgGoto(mountpoints, error); - else - virCheckNullArgGoto(mountpoints, error); + virCheckNonNullArrayArgGoto(mountpoints, nmountpoints, error); =20 if (dom->conn->driver->domainFSThaw) { int ret =3D dom->conn->driver->domainFSThaw( diff --git a/src/libvirt-host.c b/src/libvirt-host.c index 221a1b7a43..94ba5a8e80 100644 --- a/src/libvirt-host.c +++ b/src/libvirt-host.c @@ -910,7 +910,7 @@ virNodeGetCellsFreeMemory(virConnectPtr conn, unsigned = long long *freeMems, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(freeMems, error); + virCheckNonNullArrayArgGoto(freeMems, maxCells, error); virCheckPositiveArgGoto(maxCells, error); virCheckNonNegativeArgGoto(startCell, error); =20 diff --git a/src/libvirt-interface.c b/src/libvirt-interface.c index 7228ddca57..2d2df68131 100644 --- a/src/libvirt-interface.c +++ b/src/libvirt-interface.c @@ -166,7 +166,7 @@ virConnectListInterfaces(virConnectPtr conn, char **con= st names, int maxnames) virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->interfaceDriver && conn->interfaceDriver->connectListInterfa= ces) { @@ -245,7 +245,7 @@ virConnectListDefinedInterfaces(virConnectPtr conn, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->interfaceDriver && conn->interfaceDriver->connectListDefined= Interfaces) { diff --git a/src/libvirt-network.c b/src/libvirt-network.c index 146ccc5e4a..09e24fb0a8 100644 --- a/src/libvirt-network.c +++ b/src/libvirt-network.c @@ -175,7 +175,7 @@ virConnectListNetworks(virConnectPtr conn, char **const= names, int maxnames) virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->networkDriver && conn->networkDriver->connectListNetworks) { @@ -252,7 +252,7 @@ virConnectListDefinedNetworks(virConnectPtr conn, char = **const names, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->networkDriver && conn->networkDriver->connectListDefinedNetw= orks) { diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index 10050b193b..dce46b7181 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -169,7 +169,7 @@ virNodeListDevices(virConnectPtr conn, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->nodeDeviceDriver && conn->nodeDeviceDriver->nodeListDevices)= { @@ -415,7 +415,7 @@ virNodeDeviceListCaps(virNodeDevicePtr dev, virResetLastError(); =20 virCheckNodeDeviceReturn(dev, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDe= viceListCaps) { diff --git a/src/libvirt-nwfilter.c b/src/libvirt-nwfilter.c index 16eceb6525..d28220db8a 100644 --- a/src/libvirt-nwfilter.c +++ b/src/libvirt-nwfilter.c @@ -127,7 +127,7 @@ virConnectListNWFilters(virConnectPtr conn, char **cons= t names, int maxnames) virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->nwfilterDriver && conn->nwfilterDriver->connectListNWFilters= ) { diff --git a/src/libvirt-secret.c b/src/libvirt-secret.c index 711c4fc580..33cbdd7b0b 100644 --- a/src/libvirt-secret.c +++ b/src/libvirt-secret.c @@ -166,7 +166,7 @@ virConnectListSecrets(virConnectPtr conn, char **uuids,= int maxuuids) virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(uuids, error); + virCheckNonNullArrayArgGoto(uuids, maxuuids, error); virCheckNonNegativeArgGoto(maxuuids, error); =20 if (conn->secretDriver !=3D NULL && conn->secretDriver->connectListSec= rets !=3D NULL) { diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index 05b2365692..0406fe84d3 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -197,7 +197,7 @@ virConnectListStoragePools(virConnectPtr conn, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->storageDriver && conn->storageDriver->connectListStoragePool= s) { @@ -277,7 +277,7 @@ virConnectListDefinedStoragePools(virConnectPtr conn, virResetLastError(); =20 virCheckConnectReturn(conn, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (conn->storageDriver && conn->storageDriver->connectListDefinedStor= agePools) { @@ -1268,7 +1268,7 @@ virStoragePoolListVolumes(virStoragePoolPtr pool, virResetLastError(); =20 virCheckStoragePoolReturn(pool, -1); - virCheckNonNullArgGoto(names, error); + virCheckNonNullArrayArgGoto(names, maxnames, error); virCheckNonNegativeArgGoto(maxnames, error); =20 if (pool->conn->storageDriver && pool->conn->storageDriver->storagePoo= lListVolumes) { --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list