ng_parse: IP address parsing in netgraph eating too many characters

Once the final component of the IP address has been parsed, the offset
on the input must not be advanced, as this would remove an unparsed
character from the input.

Submitted by:	Markus Stoff
Reviewed by:	donner
MFC after:	3 weeks
Differential Revision: https://reviews.freebsd.org/D26489
This commit is contained in:
Markus Stoff 2021-05-18 22:35:33 +02:00 committed by Lutz Donnerhacke
parent 7fd8baee75
commit 63b6a08ce2

@ -960,9 +960,11 @@ ng_ipaddr_parse(const struct ng_parse_type *type,
if ((error = ng_int8_parse(&ng_parse_int8_type,
s, off, start, buf + i, buflen)) != 0)
return (error);
if (i < 3 && s[*off] != '.')
return (EINVAL);
(*off)++;
if (i < 3) {
if (s[*off] != '.')
return (EINVAL);
(*off)++;
}
}
*buflen = 4;
return (0);