Skip to content

Commit 83f03fa

Browse files
Jerome BorsboomDavid S. Miller
Jerome Borsboom
authored and
David S. Miller
committed
[NET]: parse ip:port strings correctly in in4_pton
in4_pton converts a textual representation of an ip4 address into an integer representation. However, when the textual representation is of in the form ip:port, e.g. 192.168.1.1:5060, and 'delim' is set to -1, the function bails out with an error when reading the colon. It makes sense to allow the colon as a delimiting character without explicitly having to set it through the 'delim' variable as there can be no ambiguity in the point where the ip address is completely parsed. This function is indeed called from nf_conntrack_sip.c in this way to parse textual ip:port combinations which fails due to the reason stated above. Signed-off-by: Jerome Borsboom <j.borsboom@erasmusmc.nl> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ebba6d commit 83f03fa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/core/utils.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ int in4_pton(const char *src, int srclen,
139139
while(1) {
140140
int c;
141141
c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
142-
if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM))) {
142+
if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK))) {
143143
goto out;
144144
}
145-
if (c & (IN6PTON_DOT | IN6PTON_DELIM)) {
145+
if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
146146
if (w == 0)
147147
goto out;
148148
*d++ = w & 0xff;
149149
w = 0;
150150
i++;
151-
if (c & IN6PTON_DELIM) {
151+
if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
152152
if (i != 4)
153153
goto out;
154154
break;

0 commit comments

Comments
 (0)