]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/nf_conntrack_irc.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394...
[linux-2.6-omap-h63xx.git] / net / netfilter / nf_conntrack_irc.c
index 1b1226d6653f7815970483cdba636c5f22a3934e..409c8be58e7c3fe097ceacc47c37ffb8092a155a 100644 (file)
@@ -41,6 +41,7 @@ MODULE_AUTHOR("Harald Welte <laforge@netfilter.org>");
 MODULE_DESCRIPTION("IRC (DCC) connection tracking helper");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS("ip_conntrack_irc");
+MODULE_ALIAS_NFCT_HELPER("irc");
 
 module_param_array(ports, ushort, &ports_c, 0400);
 MODULE_PARM_DESC(ports, "port numbers of IRC servers");
@@ -68,11 +69,21 @@ static const char *const dccprotos[] = {
 static int parse_dcc(char *data, const char *data_end, u_int32_t *ip,
                     u_int16_t *port, char **ad_beg_p, char **ad_end_p)
 {
+       char *tmp;
+
        /* at least 12: "AAAAAAAA P\1\n" */
        while (*data++ != ' ')
                if (data > data_end - 12)
                        return -1;
 
+       /* Make sure we have a newline character within the packet boundaries
+        * because simple_strtoul parses until the first invalid character. */
+       for (tmp = data; tmp <= data_end; tmp++)
+               if (*tmp == '\n')
+                       break;
+       if (tmp > data_end || *tmp != '\n')
+               return -1;
+
        *ad_beg_p = data;
        *ip = simple_strtoul(data, &data, 10);
 
@@ -146,9 +157,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,
                /* we have at least (19+MINMATCHLEN)-5 bytes valid data left */
 
                iph = ip_hdr(skb);
-               pr_debug("DCC found in master %u.%u.%u.%u:%u %u.%u.%u.%u:%u\n",
-                        NIPQUAD(iph->saddr), ntohs(th->source),
-                        NIPQUAD(iph->daddr), ntohs(th->dest));
+               pr_debug("DCC found in master %pI4:%u %pI4:%u\n",
+                        &iph->saddr, ntohs(th->source),
+                        &iph->daddr, ntohs(th->dest));
 
                for (i = 0; i < ARRAY_SIZE(dccprotos); i++) {
                        if (memcmp(data, dccprotos[i], strlen(dccprotos[i]))) {
@@ -175,10 +186,9 @@ static int help(struct sk_buff *skb, unsigned int protoff,
                            tuple->dst.u3.ip != htonl(dcc_ip)) {
                                if (net_ratelimit())
                                        printk(KERN_WARNING
-                                               "Forged DCC command from "
-                                               "%u.%u.%u.%u: %u.%u.%u.%u:%u\n",
-                                               NIPQUAD(tuple->src.u3.ip),
-                                               HIPQUAD(dcc_ip), dcc_port);
+                                               "Forged DCC command from %pI4: %pI4:%u\n",
+                                               &tuple->src.u3.ip,
+                                               &dcc_ip, dcc_port);
                                continue;
                        }