From nobody Sun May 5 00:56:18 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490618552067565.0698543653635; Mon, 27 Mar 2017 05:42:32 -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 A7333C03BD77; Mon, 27 Mar 2017 12:42:30 +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 75F6980696; Mon, 27 Mar 2017 12:42: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 29D4418523CE; Mon, 27 Mar 2017 12:42: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 v2RCgCX5020163 for ; Mon, 27 Mar 2017 08:42:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7FAAC189F1; Mon, 27 Mar 2017 12:42:12 +0000 (UTC) Received: from dnr.brq.redhat.com (dhcp129-199.brq.redhat.com [10.34.129.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05626189E6 for ; Mon, 27 Mar 2017 12:42:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A7333C03BD77 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A7333C03BD77 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 27 Mar 2017 14:42:07 +0200 Message-Id: <7b7ee296e00e0db076e1083e63847e9d21500ec0.1490618487.git.jtomko@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/2] storage: reject negative capacity 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]); Mon, 27 Mar 2017 12:42:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1436119 --- src/conf/storage_conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 6b34cea..28277e5 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -1063,7 +1063,7 @@ virStorageSize(const char *unit, const char *val, unsigned long long *ret) { - if (virStrToLong_ull(val, NULL, 10, ret) < 0) { + if (virStrToLong_ullp(val, NULL, 10, ret) < 0) { virReportError(VIR_ERR_XML_ERROR, "%s", _("malformed capacity element")); return -1; --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sun May 5 00:56:18 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.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1490618556033398.66874436312446; Mon, 27 Mar 2017 05:42:36 -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 75A61445D1; Mon, 27 Mar 2017 12:42:34 +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 463A118A2F; Mon, 27 Mar 2017 12:42:34 +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 EA63118523CF; Mon, 27 Mar 2017 12:42:33 +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 v2RCgDpM020171 for ; Mon, 27 Mar 2017 08:42:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 52BC2189F1; Mon, 27 Mar 2017 12:42:13 +0000 (UTC) Received: from dnr.brq.redhat.com (dhcp129-199.brq.redhat.com [10.34.129.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id CE8B8189E6 for ; Mon, 27 Mar 2017 12:42:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 75A61445D1 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 75A61445D1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Date: Mon, 27 Mar 2017 14:42:08 +0200 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/2] virsh: reject more negative numbers 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.30]); Mon, 27 Mar 2017 12:42:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Be more positive and reject negative numbers where we don't allow them by using the virStrToLong variants with 'p'. https://bugzilla.redhat.com/show_bug.cgi?id=3D1436119 --- tools/virsh-domain.c | 22 +++++++++++----------- tools/virsh-host.c | 6 +++--- tools/virsh-volume.c | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 2269146..4b6c13c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -438,19 +438,19 @@ static int str2PCIAddress(const char *str, struct PCI= Address *pciAddr) =20 domain =3D (char *)str; =20 - if (virStrToLong_ui(domain, &bus, 16, &pciAddr->domain) !=3D 0) + if (virStrToLong_uip(domain, &bus, 16, &pciAddr->domain) !=3D 0) return -1; =20 bus++; - if (virStrToLong_ui(bus, &slot, 16, &pciAddr->bus) !=3D 0) + if (virStrToLong_uip(bus, &slot, 16, &pciAddr->bus) !=3D 0) return -1; =20 slot++; - if (virStrToLong_ui(slot, &function, 16, &pciAddr->slot) !=3D 0) + if (virStrToLong_uip(slot, &function, 16, &pciAddr->slot) !=3D 0) return -1; =20 function++; - if (virStrToLong_ui(function, NULL, 16, &pciAddr->function) !=3D 0) + if (virStrToLong_uip(function, NULL, 16, &pciAddr->function) !=3D 0) return -1; =20 return 0; @@ -492,15 +492,15 @@ static int str2IDEAddress(const char *str, struct IDE= Address *ideAddr) =20 controller =3D (char *)str; =20 - if (virStrToLong_ui(controller, &bus, 10, &ideAddr->controller) !=3D 0) + if (virStrToLong_uip(controller, &bus, 10, &ideAddr->controller) !=3D = 0) return -1; =20 bus++; - if (virStrToLong_ui(bus, &unit, 10, &ideAddr->bus) !=3D 0) + if (virStrToLong_uip(bus, &unit, 10, &ideAddr->bus) !=3D 0) return -1; =20 unit++; - if (virStrToLong_ui(unit, NULL, 10, &ideAddr->unit) !=3D 0) + if (virStrToLong_uip(unit, NULL, 10, &ideAddr->unit) !=3D 0) return -1; =20 return 0; @@ -517,15 +517,15 @@ static int str2CCWAddress(const char *str, struct CCW= Address *ccwAddr) =20 cssid =3D (char *)str; =20 - if (virStrToLong_ui(cssid, &ssid, 16, &ccwAddr->cssid) !=3D 0) + if (virStrToLong_uip(cssid, &ssid, 16, &ccwAddr->cssid) !=3D 0) return -1; =20 ssid++; - if (virStrToLong_ui(ssid, &devno, 16, &ccwAddr->ssid) !=3D 0) + if (virStrToLong_uip(ssid, &devno, 16, &ccwAddr->ssid) !=3D 0) return -1; =20 devno++; - if (virStrToLong_ui(devno, NULL, 16, &ccwAddr->devno) !=3D 0) + if (virStrToLong_uip(devno, NULL, 16, &ccwAddr->devno) !=3D 0) return -1; =20 return 0; @@ -8428,7 +8428,7 @@ virshKeyCodeGetInt(const char *key_name) { unsigned int val; =20 - if (virStrToLong_ui(key_name, NULL, 0, &val) < 0 || val > 0xffff) + if (virStrToLong_uip(key_name, NULL, 0, &val) < 0 || val > 0xffff) return -1; return val; } diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 24ebde2..3b86c75 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -209,7 +209,7 @@ cmdFreecell(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < nodes_cnt; i++) { unsigned long id; char *val =3D virXMLPropString(nodes[i], "id"); - if (virStrToLong_ul(val, NULL, 10, &id)) { + if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); VIR_FREE(val); goto cleanup; @@ -355,7 +355,7 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < nodes_cnt; i++) { char *val =3D virXMLPropString(nodes[i], "size"); =20 - if (virStrToLong_ui(val, NULL, 10, &pagesize[i]) < 0) { + if (virStrToLong_uip(val, NULL, 10, &pagesize[i]) < 0) { vshError(ctl, _("unable to parse page size: %s"), val); VIR_FREE(val); goto cleanup; @@ -554,7 +554,7 @@ cmdAllocpages(vshControl *ctl, const vshCmd *cmd) for (i =3D 0; i < nodes_cnt; i++) { unsigned long id; char *val =3D virXMLPropString(nodes[i], "id"); - if (virStrToLong_ul(val, NULL, 10, &id)) { + if (virStrToLong_ulp(val, NULL, 10, &id)) { vshError(ctl, "%s", _("conversion from string failed")); VIR_FREE(val); goto cleanup; diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 02ed044..32ffb81 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -206,7 +206,7 @@ static int virshVolSize(const char *data, unsigned long long *val) { char *end; - if (virStrToLong_ull(data, &end, 10, val) < 0) + if (virStrToLong_ullp(data, &end, 10, val) < 0) return -1; return virScaleInteger(val, end, 1, ULLONG_MAX); } --=20 2.10.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list