Commit 83f03fa5 authored by Jerome Borsboom's avatar Jerome Borsboom Committed by David S. Miller

[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: default avatarJerome Borsboom <j.borsboom@erasmusmc.nl>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7ebba6d1
...@@ -139,16 +139,16 @@ int in4_pton(const char *src, int srclen, ...@@ -139,16 +139,16 @@ int in4_pton(const char *src, int srclen,
while(1) { while(1) {
int c; int c;
c = xdigit2bin(srclen > 0 ? *s : '\0', delim); c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM))) { if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK))) {
goto out; goto out;
} }
if (c & (IN6PTON_DOT | IN6PTON_DELIM)) { if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
if (w == 0) if (w == 0)
goto out; goto out;
*d++ = w & 0xff; *d++ = w & 0xff;
w = 0; w = 0;
i++; i++;
if (c & IN6PTON_DELIM) { if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
if (i != 4) if (i != 4)
goto out; goto out;
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment