aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2008-03-25 23:17:36 -0400
committerDavid S. Miller <davem@davemloft.net>2008-03-25 23:17:36 -0400
commit779382eb324ad0c39f8c4d10a47a813b490ab82c (patch)
tree8bf8bb8b4588baab54ffe8f07e06e1dfe21cf9e1
parent212440a7d04a12ee13787afecc6c86c7fc4e6184 (diff)
[NETFILTER]: nf_conntrack_sip: use strlen/strcmp
Replace sizeof/memcmp by strlen/strcmp. Use case-insensitive comparison for SIP methods and the SIP/2.0 string, as specified in RFC 3261. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/netfilter/nf_nat_sip.c12
-rw-r--r--net/netfilter/nf_conntrack_sip.c12
2 files changed, 12 insertions, 12 deletions
diff --git a/net/ipv4/netfilter/nf_nat_sip.c b/net/ipv4/netfilter/nf_nat_sip.c
index acaa7d4569fa..dd1b2d86deee 100644
--- a/net/ipv4/netfilter/nf_nat_sip.c
+++ b/net/ipv4/netfilter/nf_nat_sip.c
@@ -94,12 +94,12 @@ static int map_sip_addr(struct sk_buff *skb,
94 94
95 if ((matchlen == map->addr[dir].srciplen || 95 if ((matchlen == map->addr[dir].srciplen ||
96 matchlen == map->addr[dir].srclen) && 96 matchlen == map->addr[dir].srclen) &&
97 memcmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) { 97 strncmp(*dptr + matchoff, map->addr[dir].src, matchlen) == 0) {
98 addr = map->addr[!dir].dst; 98 addr = map->addr[!dir].dst;
99 addrlen = map->addr[!dir].dstlen; 99 addrlen = map->addr[!dir].dstlen;
100 } else if ((matchlen == map->addr[dir].dstiplen || 100 } else if ((matchlen == map->addr[dir].dstiplen ||
101 matchlen == map->addr[dir].dstlen) && 101 matchlen == map->addr[dir].dstlen) &&
102 memcmp(*dptr + matchoff, map->addr[dir].dst, matchlen) == 0) { 102 strncmp(*dptr + matchoff, map->addr[dir].dst, matchlen) == 0) {
103 addr = map->addr[!dir].src; 103 addr = map->addr[!dir].src;
104 addrlen = map->addr[!dir].srclen; 104 addrlen = map->addr[!dir].srclen;
105 } else 105 } else
@@ -117,20 +117,20 @@ static unsigned int ip_nat_sip(struct sk_buff *skb,
117 enum sip_header_pos pos; 117 enum sip_header_pos pos;
118 struct addr_map map; 118 struct addr_map map;
119 119
120 if (*datalen < sizeof("SIP/2.0") - 1) 120 if (*datalen < strlen("SIP/2.0"))
121 return NF_ACCEPT; 121 return NF_ACCEPT;
122 122
123 addr_map_init(ct, &map); 123 addr_map_init(ct, &map);
124 124
125 /* Basic rules: requests and responses. */ 125 /* Basic rules: requests and responses. */
126 if (strncmp(*dptr, "SIP/2.0", sizeof("SIP/2.0") - 1) != 0) { 126 if (strnicmp(*dptr, "SIP/2.0", strlen("SIP/2.0")) != 0) {
127 /* 10.2: Constructing the REGISTER Request: 127 /* 10.2: Constructing the REGISTER Request:
128 * 128 *
129 * The "userinfo" and "@" components of the SIP URI MUST NOT 129 * The "userinfo" and "@" components of the SIP URI MUST NOT
130 * be present. 130 * be present.
131 */ 131 */
132 if (*datalen >= sizeof("REGISTER") - 1 && 132 if (*datalen >= strlen("REGISTER") &&
133 strncmp(*dptr, "REGISTER", sizeof("REGISTER") - 1) == 0) 133 strnicmp(*dptr, "REGISTER", strlen("REGISTER")) == 0)
134 pos = POS_REG_REQ_URI; 134 pos = POS_REG_REQ_URI;
135 else 135 else
136 pos = POS_REQ_URI; 136 pos = POS_REQ_URI;
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index 38e1e7a05334..cf19a7082a75 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -434,15 +434,15 @@ static int sip_help(struct sk_buff *skb,
434 } 434 }
435 435
436 datalen = skb->len - dataoff; 436 datalen = skb->len - dataoff;
437 if (datalen < sizeof("SIP/2.0 200") - 1) 437 if (datalen < strlen("SIP/2.0 200"))
438 goto out; 438 goto out;
439 439
440 /* RTP info only in some SDP pkts */ 440 /* RTP info only in some SDP pkts */
441 if (memcmp(dptr, "INVITE", sizeof("INVITE") - 1) != 0 && 441 if (strnicmp(dptr, "INVITE", strlen("INVITE")) != 0 &&
442 memcmp(dptr, "UPDATE", sizeof("UPDATE") - 1) != 0 && 442 strnicmp(dptr, "UPDATE", strlen("UPDATE")) != 0 &&
443 memcmp(dptr, "SIP/2.0 180", sizeof("SIP/2.0 180") - 1) != 0 && 443 strnicmp(dptr, "SIP/2.0 180", strlen("SIP/2.0 180")) != 0 &&
444 memcmp(dptr, "SIP/2.0 183", sizeof("SIP/2.0 183") - 1) != 0 && 444 strnicmp(dptr, "SIP/2.0 183", strlen("SIP/2.0 183")) != 0 &&
445 memcmp(dptr, "SIP/2.0 200", sizeof("SIP/2.0 200") - 1) != 0) { 445 strnicmp(dptr, "SIP/2.0 200", strlen("SIP/2.0 200")) != 0) {
446 goto out; 446 goto out;
447 } 447 }
448 /* Get address and port from SDP packet. */ 448 /* Get address and port from SDP packet. */