]> xenbits.xensource.com Git - libvirt.git/commitdiff
* src/virsh.c: vshCommandOptInt was broken as it would not
authorDaniel Veillard <veillard@redhat.com>
Thu, 16 Aug 2007 13:21:36 +0000 (13:21 +0000)
committerDaniel Veillard <veillard@redhat.com>
Thu, 16 Aug 2007 13:21:36 +0000 (13:21 +0000)
  detect non-int inputs, problem raised by Masayuki Sunou
Daniel

ChangeLog
src/virsh.c

index 618dab68adacd239880ca5971e7a7084570e2e6c..95660481bf3d072cef1e4828bfd28cfa00d22000 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Aug 16 15:24:30 CEST 2007 Daniel Veillard <veillard@redhat.com>
+
+       * src/virsh.c: vshCommandOptInt was broken as it would not
+         detect non-int inputs, problem raised by Masayuki Sunou
+
 Wed Aug 15 12:21:13 CEST 2007 Daniel Veillard <veillard@redhat.com>
 
        * src/virsh.c: fixed 2 small bugs in setvcpus command, after
index 5ad356572c4857bf6746d761f6b83f62f80dd721..69dc559dfd7a5cf8ac21425701677a71787a0074 100644 (file)
@@ -3699,12 +3699,18 @@ static int
 vshCommandOptInt(vshCmd * cmd, const char *name, int *found)
 {
     vshCmdOpt *arg = vshCommandOpt(cmd, name);
-    int res = 0;
+    int res = 0, num_found = FALSE;
+    char *end_p = NULL;
 
-    if (arg)
-        res = atoi(arg->data);
+    if ((arg != NULL) && (arg->data != NULL)) {
+        res = strtol(arg->data, &end_p, 10);
+       if ((arg->data == end_p) || (*end_p!= 0))
+           num_found = FALSE;
+       else
+           num_found = TRUE;
+    }
     if (found)
-        *found = arg ? TRUE : FALSE;
+        *found = num_found;
     return res;
 }