[PATCH 2/2] virsh: reject more negative numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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=1436119
---
 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 PCIAddress *pciAddr)
 
     domain = (char *)str;
 
-    if (virStrToLong_ui(domain, &bus, 16, &pciAddr->domain) != 0)
+    if (virStrToLong_uip(domain, &bus, 16, &pciAddr->domain) != 0)
         return -1;
 
     bus++;
-    if (virStrToLong_ui(bus, &slot, 16, &pciAddr->bus) != 0)
+    if (virStrToLong_uip(bus, &slot, 16, &pciAddr->bus) != 0)
         return -1;
 
     slot++;
-    if (virStrToLong_ui(slot, &function, 16, &pciAddr->slot) != 0)
+    if (virStrToLong_uip(slot, &function, 16, &pciAddr->slot) != 0)
         return -1;
 
     function++;
-    if (virStrToLong_ui(function, NULL, 16, &pciAddr->function) != 0)
+    if (virStrToLong_uip(function, NULL, 16, &pciAddr->function) != 0)
         return -1;
 
     return 0;
@@ -492,15 +492,15 @@ static int str2IDEAddress(const char *str, struct IDEAddress *ideAddr)
 
     controller = (char *)str;
 
-    if (virStrToLong_ui(controller, &bus, 10, &ideAddr->controller) != 0)
+    if (virStrToLong_uip(controller, &bus, 10, &ideAddr->controller) != 0)
         return -1;
 
     bus++;
-    if (virStrToLong_ui(bus, &unit, 10, &ideAddr->bus) != 0)
+    if (virStrToLong_uip(bus, &unit, 10, &ideAddr->bus) != 0)
         return -1;
 
     unit++;
-    if (virStrToLong_ui(unit, NULL, 10, &ideAddr->unit) != 0)
+    if (virStrToLong_uip(unit, NULL, 10, &ideAddr->unit) != 0)
         return -1;
 
     return 0;
@@ -517,15 +517,15 @@ static int str2CCWAddress(const char *str, struct CCWAddress *ccwAddr)
 
     cssid = (char *)str;
 
-    if (virStrToLong_ui(cssid, &ssid, 16, &ccwAddr->cssid) != 0)
+    if (virStrToLong_uip(cssid, &ssid, 16, &ccwAddr->cssid) != 0)
         return -1;
 
     ssid++;
-    if (virStrToLong_ui(ssid, &devno, 16, &ccwAddr->ssid) != 0)
+    if (virStrToLong_uip(ssid, &devno, 16, &ccwAddr->ssid) != 0)
         return -1;
 
     devno++;
-    if (virStrToLong_ui(devno, NULL, 16, &ccwAddr->devno) != 0)
+    if (virStrToLong_uip(devno, NULL, 16, &ccwAddr->devno) != 0)
         return -1;
 
     return 0;
@@ -8428,7 +8428,7 @@ virshKeyCodeGetInt(const char *key_name)
 {
     unsigned int val;
 
-    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 = 0; i < nodes_cnt; i++) {
             unsigned long id;
             char *val = 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 = 0; i < nodes_cnt; i++) {
                 char *val = virXMLPropString(nodes[i], "size");
 
-                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 = 0; i < nodes_cnt; i++) {
             unsigned long id;
             char *val = 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);
 }
-- 
2.10.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux