lib: Use wrapper for string to integer conversion
[samba.git] / source3 / lib / interface.c
index a3bc5d24e9114774991747492f577b02fbe434e0..342c92a61a2185bdcb1a6c4d08695f46d56d4310 100644 (file)
@@ -358,6 +358,7 @@ static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
        while (key != NULL && *key != '\0') {
                char *next_key;
                char *val;
+               int error = 0;
 
                next_key = strchr_m(key, ',');
                if (next_key != NULL) {
@@ -369,7 +370,10 @@ static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
                        *val++ = 0;
 
                        if (strequal_m(key, "speed")) {
-                               *speed = (uint64_t)strtoull(val, NULL, 0);
+                               *speed = (uint64_t)strtoull_err(val, NULL, 0, &error);
+                               if (error != 0) {
+                                       DBG_DEBUG("Invalid speed value (%s)\n", val);
+                               }
                        } else if (strequal_m(key, "capability")) {
                                if (strequal_m(val, "RSS")) {
                                        *cap |= FSCTL_NET_IFACE_RSS_CAPABLE;
@@ -380,7 +384,10 @@ static void parse_extra_info(char *key, uint64_t *speed, uint32_t *cap,
                                                    "'%s'\n", val);
                                }
                        } else if (strequal_m(key, "if_index")) {
-                               *if_index = (uint32_t)strtoul(val, NULL, 0);
+                               *if_index = (uint32_t)strtoul_err(val, NULL, 0, &error);
+                               if (error != 0) {
+                                       DBG_DEBUG("Invalid key value (%s)\n", val);
+                               }
                        } else {
                                DBG_DEBUG("Key unknown: '%s'\n", key);
                        }
@@ -515,9 +522,12 @@ static void interpret_interface(char *token)
                        return;
                }
        } else {
+               int error = 0;
                char *endp = NULL;
-               unsigned long val = strtoul(p, &endp, 0);
-               if (p == endp || (endp && *endp != '\0')) {
+               unsigned long val;
+
+               val = strtoul_err(p, &endp, 0, &error);
+               if (p == endp || (endp && *endp != '\0') || error != 0) {
                        DEBUG(2,("interpret_interface: "
                                "can't determine netmask value from %s\n",
                                p));