aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Stoff <markus@stoffdv.at>2021-05-18 20:35:33 +0000
committerLutz Donnerhacke <donner@FreeBSD.org>2021-06-08 10:26:09 +0000
commit90e161ec6d1127f30f92bf0b8c59dd4bd5a8bc26 (patch)
tree671a69ee01998f2e2e8ffe19f9dfb8d9fd3cc402
parentd9d03b5409f32668a71468975d944ac1015e878b (diff)
downloadsrc-90e161ec6d1127f30f92bf0b8c59dd4bd5a8bc26.tar.gz
src-90e161ec6d1127f30f92bf0b8c59dd4bd5a8bc26.zip
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 Differential Revision: https://reviews.freebsd.org/D26489 (cherry picked from commit 63b6a08ce2467b8e230e7a4ecb3e1ddf1b48851c)
-rw-r--r--sys/netgraph/ng_parse.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c
index b08cecd102e9..7297756c796d 100644
--- a/sys/netgraph/ng_parse.c
+++ b/sys/netgraph/ng_parse.c
@@ -961,9 +961,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);