psd: use skb_header_pointer

Do not rely on tcphdr being in the linear area.

Signed-off-by: Florian Westphal <fwestphal@astaro.com>
This commit is contained in:
Florian Westphal
2009-09-11 11:05:54 +02:00
committed by Jan Engelhardt
parent 83e474f9ab
commit adabd647b1

View File

@@ -102,8 +102,9 @@ static inline int hashfunc(struct in_addr addr)
static bool
xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
{
struct iphdr *iph;
struct tcphdr *tcph;
const struct iphdr *iph;
const struct tcphdr *tcph;
struct tcphdr _tcph;
struct in_addr addr;
u_int16_t src_port,dest_port;
u_int8_t tcp_flags, proto;
@@ -134,7 +135,9 @@ xt_psd_match(const struct sk_buff *pskb, const struct xt_match_param *match)
addr.s_addr = iph->saddr;
tcph = (void *)iph + ip_hdrlen(pskb);
tcph = skb_header_pointer(pskb, match->thoff, sizeof(_tcph), &_tcph);
if (tcph == NULL)
return false;
/* Yep, it's dirty */
src_port = tcph->source;