]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.20.14/net-parse-ip-port-strings-correctly-in-in4_pton.patch
Linux 4.14.95
[thirdparty/kernel/stable-queue.git] / releases / 2.6.20.14 / net-parse-ip-port-strings-correctly-in-in4_pton.patch
1 From stable-bounces@linux.kernel.org Wed Jun 6 22:40:19 2007
2 Date: Wed, 06 Jun 2007 22:40:27 -0700 (PDT)
3 Message-Id: <20070606.224027.02298887.davem@davemloft.net>
4 To: stable@kernel.org
5 From: David Miller <davem@davemloft.net>
6 Cc: bunk@stusta.de
7 Subject: NET: parse ip:port strings correctly in in4_pton
8
9 From: Jerome Borsboom <j.borsboom@erasmusmc.nl>
10
11 in4_pton converts a textual representation of an ip4 address
12 into an integer representation. However, when the textual representation
13 is of in the form ip:port, e.g. 192.168.1.1:5060, and 'delim' is set to
14 -1, the function bails out with an error when reading the colon.
15
16 It makes sense to allow the colon as a delimiting character without
17 explicitly having to set it through the 'delim' variable as there can be
18 no ambiguity in the point where the ip address is completely parsed. This
19 function is indeed called from nf_conntrack_sip.c in this way to parse
20 textual ip:port combinations which fails due to the reason stated above.
21
22 Signed-off-by: Jerome Borsboom <j.borsboom@erasmusmc.nl>
23 Signed-off-by: David S. Miller <davem@davemloft.net>
24 Signed-off-by: Chris Wright <chrisw@sous-sol.org>
25
26 ---
27 net/core/utils.c | 6 +++---
28 1 file changed, 3 insertions(+), 3 deletions(-)
29
30 --- linux-2.6.20.13.orig/net/core/utils.c
31 +++ linux-2.6.20.13/net/core/utils.c
32 @@ -137,16 +137,16 @@ int in4_pton(const char *src, int srclen
33 while(1) {
34 int c;
35 c = xdigit2bin(srclen > 0 ? *s : '\0', delim);
36 - if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM))) {
37 + if (!(c & (IN6PTON_DIGIT | IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK))) {
38 goto out;
39 }
40 - if (c & (IN6PTON_DOT | IN6PTON_DELIM)) {
41 + if (c & (IN6PTON_DOT | IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
42 if (w == 0)
43 goto out;
44 *d++ = w & 0xff;
45 w = 0;
46 i++;
47 - if (c & IN6PTON_DELIM) {
48 + if (c & (IN6PTON_DELIM | IN6PTON_COLON_MASK)) {
49 if (i != 4)
50 goto out;
51 break;