]> xenbits.xensource.com Git - libvirt.git/commitdiff
phyp: Break potential infinite loops
authorMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 6 Nov 2009 00:53:24 +0000 (01:53 +0100)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Fri, 6 Nov 2009 20:28:49 +0000 (21:28 +0100)
src/phyp/phyp_driver.c

index 5379cd3313dc85db6c5b8c752dca7296700090ad..b94d0faa067af1209c57ff12e101726db15ce651 100644 (file)
@@ -1040,9 +1040,13 @@ phypListDomainsGeneric(virConnectPtr conn, int *ids, int nids,
         goto err;
     else {
         while (got < nids) {
-            if (ret[i] == '\n') {
-                if (virStrToLong_i(id_c, &char_ptr, 10, &ids[got]) == -1)
-                    return 0;
+            if (ret[i] == '\0')
+                break;
+            else if (ret[i] == '\n') {
+                if (virStrToLong_i(id_c, &char_ptr, 10, &ids[got]) == -1) {
+                    VIR_ERROR("Cannot parse number from '%s'", id_c);
+                    goto err;
+                }
                 memset(id_c, 0, 10);
                 j = 0;
                 got++;
@@ -1112,7 +1116,8 @@ phypListDefinedDomains(virConnectPtr conn, char **const names, int nnames)
                 }
                 char_ptr2++;
                 domains = char_ptr2;
-            }
+            } else
+                break;
         }
     }