From: Max Kellermann <max@duempel.org>
To: netfilter-devel@lists.netfilter.org
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Subject: [PATCH pom-ng 3/3] h323-conntrack-nat updates: simplified length checks
Date: Thu, 12 May 2005 22:52:46 +0200 [thread overview]
Message-ID: <20050512205246.GD2175@roonstrasse.net> (raw)
In-Reply-To: <20050512204956.GA2086@roonstrasse.net>
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
h323-03-simplified_length_checks.patch
- simplified some length checks to make them easier readable
[-- Attachment #2: h323-03-simplified_length_checks.patch --]
[-- Type: text/plain, Size: 2506 bytes --]
Thu May 12 22:38:17 CEST 2005 max@duempel.org
* simplified buffer length checks
diff -rN -u old-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h225.c new-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h225.c
--- old-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h225.c 2005-05-12 22:49:00.000000000 +0200
+++ new-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h225.c 2005-05-12 22:38:36.000000000 +0200
@@ -214,7 +214,7 @@
{
struct asn1_per_buffer bb;
- if (i + 8 > length)
+ if (i + 2 > length)
return NF_ACCEPT;
if (data[i++] != 0x05) /* X.208 / X.209 */
@@ -275,6 +275,9 @@
u_int8_t q931_message_type;
unsigned length;
+ if (i + 3 > datalen)
+ return NF_ACCEPT;
+
/* parse Q.931 packet */
if (data[i++] != 0x08) /* protocol discriminator */
return NF_ACCEPT;
@@ -319,6 +322,9 @@
unsigned int i = 0;
u_int16_t tpkt_len;
+ if (i + 4 > datalen)
+ return NF_ACCEPT;
+
/* expect TPKT header, see RFC 1006 */
if (data[0] != 0x03 || data[1] != 0x00)
return NF_ACCEPT;
@@ -326,9 +332,6 @@
i += 2;
tpkt_len = ntohs(*(u_int16_t*)(data + i));
- if (tpkt_len < 16)
- return NF_ACCEPT;
-
if (tpkt_len < datalen)
datalen = tpkt_len;
@@ -372,7 +375,7 @@
}
datalen = (*pskb)->len - dataoff;
- if (datalen < 32)
+ if (datalen < 16)
return NF_ACCEPT;
/* get data portion, and evaluate it */
diff -rN -u old-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h245.c new-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h245.c
--- old-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h245.c 2005-05-12 22:49:00.000000000 +0200
+++ new-h323-0/h323-conntrack-nat/linux-2.6.11/net/ipv4/netfilter/ip_conntrack_h323_h245.c 2005-05-12 22:38:36.000000000 +0200
@@ -868,6 +868,9 @@
u_int16_t tpkt_len;
struct asn1_per_buffer bb;
+ if (i + 4 > datalen)
+ return NF_ACCEPT;
+
/* expect TPKT header, see RFC 1006 */
if (data[0] != 0x03 || data[1] != 0x00)
return NF_ACCEPT;
@@ -875,9 +878,6 @@
i += 2;
tpkt_len = ntohs(*(u_int16_t*)(data + i));
- if (tpkt_len < 16)
- return NF_ACCEPT;
-
if (tpkt_len < datalen)
datalen = tpkt_len;
@@ -922,6 +922,9 @@
}
datalen = (*pskb)->len - dataoff;
+ if (datalen < 16)
+ return NF_ACCEPT;
+
LOCK_BH(&ip_h245_lock);
data = skb_header_pointer((*pskb), dataoff,
datalen, h245_buffer);
next prev parent reply other threads:[~2005-05-12 20:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-12 20:49 [PATCH pom-ng 0/3] h323-conntrack-nat updates: buffer checks Max Kellermann
2005-05-12 20:50 ` [PATCH pom-ng 1/3] h323-conntrack-nat updates: check bb->error in every iteration Max Kellermann
2005-05-12 20:51 ` Max Kellermann
2005-05-12 20:52 ` [PATCH pom-ng 2/3] h323-conntrack-nat updates: q931_find_u2u() returns relative length Max Kellermann
2005-05-12 20:53 ` Max Kellermann
2005-05-12 20:52 ` Max Kellermann [this message]
2005-05-17 15:32 ` [PATCH pom-ng 3/3] h323-conntrack-nat updates: simplified length checks Patrick McHardy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050512205246.GD2175@roonstrasse.net \
--to=max@duempel.org \
--cc=kadlec@blackhole.kfki.hu \
--cc=netfilter-devel@lists.netfilter.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.