cmdline: allow quoted strings
[libcmdline.git] / src / lib / cmdline_parse_ipaddr.c
index 276d644..37b2f3b 100644 (file)
@@ -299,18 +299,11 @@ cmdline_parse_ipaddr(cmdline_parse_token_hdr_t *tk, const char *buf, void *res)
        char *prefix, *prefix_end;
        long prefixlen;
 
-       if (! *buf)
-               return -1;
-
-       while (!cmdline_isendoftoken(buf[token_len]))
-               token_len++;
-
        /* if token is too big... */
-       if (token_len >= INET6_ADDRSTRLEN+4)
+       token_len = snprintf(ip_str, sizeof(ip_str), "%s", buf);
+       if (token_len >= sizeof(ip_str))
                return -1;
 
-       snprintf(ip_str, token_len+1, "%s", buf);
-
        /* convert the network prefix */
        if (tk2->ipaddr_data.flags & CMDLINE_IPADDR_NETWORK) {
                prefix = strrchr(ip_str, '/');