Skip to content

Commit

Permalink
ng_parse: IP address parsing in netgraph eating too many characters
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Markus Stoff authored and Lutz Donnerhacke committed May 18, 2021
1 parent 7fd8bae commit 63b6a08
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sys/netgraph/ng_parse.c
Expand Up @@ -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);
Expand Down

0 comments on commit 63b6a08

Please sign in to comment.