From nobody Wed Nov 27 16:37:07 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 1542733994226445.04714252007614; Tue, 20 Nov 2018 09:13:14 -0800 (PST) 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 C3BD43DBC2; Tue, 20 Nov 2018 17:13:11 +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 4E4F8A63D7; Tue, 20 Nov 2018 17:13:11 +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 EA57D3F605; Tue, 20 Nov 2018 17:13:10 +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 wAKHDAcb020973 for ; Tue, 20 Nov 2018 12:13:10 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6A74818F02; Tue, 20 Nov 2018 17:13:09 +0000 (UTC) Received: from unknown4CEB42C824F4.redhat.com (ovpn-117-6.phx2.redhat.com [10.3.117.6]) by smtp.corp.redhat.com (Postfix) with ESMTP id 522AD18B5E for ; Tue, 20 Nov 2018 17:13:07 +0000 (UTC) From: John Ferlan To: libvir-list@redhat.com Date: Tue, 20 Nov 2018 12:13:03 -0500 Message-Id: <20181120171304.16697-2-jferlan@redhat.com> In-Reply-To: <20181120171304.16697-1-jferlan@redhat.com> References: <20181120171304.16697-1-jferlan@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 1/2] Add check for params, nparams being a dictionary 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.30]); Tue, 20 Nov 2018 17:13:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" If PyDict_Check fails, we should force an error rather than blindly continuing on. Signed-off-by: John Ferlan --- libvirt-override.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libvirt-override.c b/libvirt-override.c index 0353306..8748101 100644 --- a/libvirt-override.c +++ b/libvirt-override.c @@ -7861,6 +7861,11 @@ libvirt_virDomainMigrate3(PyObject *self ATTRIBUTE_U= NUSED, domain =3D (virDomainPtr) PyvirDomain_Get(pyobj_domain); dconn =3D (virConnectPtr) PyvirConnect_Get(pyobj_dconn); =20 + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, "migration params must be a dictiona= ry"); + return NULL; + } + if (virPyDictToTypedParams(dict, ¶ms, &nparams, virPyDomainMigrate3Params, VIR_N_ELEMENTS(virPyDomainMigrate3Params)) = < 0) { @@ -7894,6 +7899,11 @@ libvirt_virDomainMigrateToURI3(PyObject *self ATTRIB= UTE_UNUSED, =20 domain =3D (virDomainPtr) PyvirDomain_Get(pyobj_domain); =20 + if (!PyDict_Check(dict)) { + PyErr_Format(PyExc_TypeError, "migration params must be a dictiona= ry"); + return NULL; + } + if (virPyDictToTypedParams(dict, ¶ms, &nparams, virPyDomainMigrate3Params, VIR_N_ELEMENTS(virPyDomainMigrate3Params)) = < 0) { @@ -8776,6 +8786,9 @@ libvirt_virDomainBlockCopy(PyObject *self ATTRIBUTE_U= NUSED, VIR_N_ELEMENTS(virPyDomainBlockCopyPara= ms)) < 0) { return NULL; } + } else { + PyErr_Format(PyExc_TypeError, "block params must be a dictionary"); + return NULL; } =20 dom =3D (virDomainPtr) PyvirDomain_Get(pyobj_dom); --=20 2.17.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list