Bug discovered by Olaf Kirch.
== tcpinfo->flg_cmp,
IPT_TCP_INV_FLAGS))
return 0;
- if (tcpinfo->option &&
- !tcp_find_option(tcpinfo->option, skb, tcph.doff*4 - sizeof(tcph),
- tcpinfo->invflags & IPT_TCP_INV_OPTION,
- hotdrop))
- return 0;
+ if (tcpinfo->option) {
+ if (tcph.doff * 4 < sizeof(tcph)) {
+ *hotdrop = 1;
+ return 0;
+ }
+ if (!tcp_find_option(tcpinfo->option, skb, tcph.doff*4 - sizeof(tcph),
+ tcpinfo->invflags & IPT_TCP_INV_OPTION,
+ hotdrop))
+ return 0;
+ }
return 1;
}
duprintf("tcp_match: finding option\n");
/* If we don't have the whole header, drop packet. */
- if (tcp->doff * 4 > datalen) {
+ if (tcp->doff * 4 < sizeof(struct tcphdr) ||
+ tcp->doff * 4 > datalen) {
*hotdrop = 1;
return 0;
}