[NETFILTER]: Fix IP/TCP option logging

Linux Kernel Mailing List <[email protected]> Fri, 04 Mar 2005 10:36:23 +0000
Newsgroups gmane.linux.kernel.commits.2-4
Message-ID <[email protected]>
ChangeSet 1.1448.125.2, 2005/03/04 11:36:23+01:00, [email protected]

	[NETFILTER]: Fix IP/TCP option logging
	
	Signed-off-by: Patrick McHardy <[email protected]>



 ipt_LOG.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)


diff -Nru a/net/ipv4/netfilter/ipt_LOG.c b/net/ipv4/netfilter/ipt_LOG.c
--- a/net/ipv4/netfilter/ipt_LOG.c	2005-03-25 17:03:02 -08:00
+++ b/net/ipv4/netfilter/ipt_LOG.c	2005-03-25 17:03:02 -08:00
@@ -67,8 +67,8 @@
 		printk("FRAG:%u ", ntohs(iph->frag_off) & IP_OFFSET);
 
 	if ((info->logflags & IPT_LOG_IPOPT)
-	    && iph->ihl * 4 != sizeof(struct iphdr)
-	    && iph->ihl * 4 >= datalen) {
+	    && iph->ihl * 4 > sizeof(struct iphdr)
+	    && iph->ihl * 4 <= len) {
 		unsigned int i;
 
 		/* Max length: 127 "OPT (" 15*4*2chars ") " */
@@ -126,7 +126,8 @@
 		printk("URGP=%u ", ntohs(tcph->urg_ptr));
 
 		if ((info->logflags & IPT_LOG_TCPOPT)
-		    && tcph->doff * 4 != sizeof(struct tcphdr)) {
+		    && tcph->doff * 4 > sizeof(struct tcphdr)
+		    && tcph->doff * 4 <= datalen) {
 			unsigned int i;
 
 			/* Max length: 127 "OPT (" 15*4*2chars ") " */