Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 8 Jun 2021 10:15:20 GMT
From:      Lutz Donnerhacke <donner@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: f18b7f239dcd - stable/13 - ng_parse: IP address parsing in netgraph eating too many characters
Message-ID:  <202106081015.158AFKAt007531@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by donner:

URL: https://cgit.FreeBSD.org/src/commit/?id=f18b7f239dcd75a192891232bc1fc099805f7d76

commit f18b7f239dcd75a192891232bc1fc099805f7d76
Author:     Markus Stoff <markus@stoffdv.at>
AuthorDate: 2021-05-18 20:35:33 +0000
Commit:     Lutz Donnerhacke <donner@FreeBSD.org>
CommitDate: 2021-06-08 10:14:34 +0000

    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)
---
 sys/netgraph/ng_parse.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sys/netgraph/ng_parse.c b/sys/netgraph/ng_parse.c
index 8050edbba562..c3c2126bdef5 100644
--- a/sys/netgraph/ng_parse.c
+++ b/sys/netgraph/ng_parse.c
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202106081015.158AFKAt007531>