]> xenbits.xensource.com Git - libvirt.git/commitdiff
Replace sscanf in nwfilter rule parsing
authorMatthias Bolte <matthias.bolte@googlemail.com>
Tue, 30 Mar 2010 13:47:59 +0000 (15:47 +0200)
committerMatthias Bolte <matthias.bolte@googlemail.com>
Thu, 1 Apr 2010 10:53:41 +0000 (12:53 +0200)
Parsing is stricter now and doesn't accept trailing characters
after the actual value anymore.

src/conf/nwfilter_conf.c

index ced3b65c3a87233de408f91a4d191f6332f9ce34..9438846ab79dc7bc6b0872831cc4e3c5d4c16369 100644 (file)
@@ -1233,7 +1233,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
 
                         case DATATYPE_UINT8:
                             storage_ptr = &item->u.u8;
-                            if (sscanf(prop, "%d", &int_val) == 1) {
+                            if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) {
                                 if (int_val >= 0 && int_val <= 0xff) {
                                     if (!validator)
                                         *(uint8_t *)storage_ptr = int_val;
@@ -1247,7 +1247,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
 
                         case DATATYPE_UINT16:
                             storage_ptr = &item->u.u16;
-                            if (sscanf(prop, "%d", &int_val) == 1) {
+                            if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) {
                                 if (int_val >= 0 && int_val <= 0xffff) {
                                     if (!validator)
                                         *(uint16_t *)storage_ptr = int_val;
@@ -1653,8 +1653,8 @@ virNWFilterRuleParse(virConnectPtr conn,
     ret->priority = MAX_RULE_PRIORITY / 2;
 
     if (prio) {
-        if (sscanf(prio, "%d", (int *)&priority) == 1) {
-            if ((int)priority >= 0 && priority <= MAX_RULE_PRIORITY)
+        if (virStrToLong_ui(prio, NULL, 10, &priority) >= 0) {
+            if (priority <= MAX_RULE_PRIORITY)
                 ret->priority = priority;
         }
     }