]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
xt_RAWNAT: skb writable part might not include whole L4 header (IPv4 case)
authorDmitry Popov <dp@highloadlab.com>
Sun, 5 May 2013 18:05:04 +0000 (20:05 +0200)
committerJan Engelhardt <jengelh@inai.de>
Wed, 8 May 2013 11:21:54 +0000 (13:21 +0200)
Consider TCP/IPv4 packet with IP options: sizeof(*iph) + sizeof(struct
tcphdr) is not enough to include tcp checksum. It may hurt if this
packet is fragmented.

Therefore, we should use iph->ihl * 4 instead of sizeof(*iph).

Signed-off-by: Dmitry Popov <dp@highloadlab.com>
doc/changelog.txt
extensions/xt_RAWNAT.c

index fd0989a4a08ec5fcafe47c6badd258f2bfa5c37d..f39b11936613998f5c962a9315bbe2a496fda84c 100644 (file)
@@ -1,6 +1,8 @@
 
 HEAD
 ====
+Fixes:
+- xt_RAWNAT: ensure correct operation in the presence of IPv4 options
 
 
 v2.2 (2013-03-31)
index a52e61441f7cb1a3a5db08960953934f0b4eb560..858f911c7c3b1a85c27f739fdb22987e027d26a5 100644 (file)
@@ -109,7 +109,7 @@ static void rawnat4_update_l4(struct sk_buff *skb, __be32 oldip, __be32 newip)
 
 static unsigned int rawnat4_writable_part(const struct iphdr *iph)
 {
-       unsigned int wlen = sizeof(*iph);
+       unsigned int wlen = iph->ihl * 4;
 
        switch (iph->protocol) {
        case IPPROTO_TCP: