Re: Question about ip_rcv() function

From: David S. Miller
Date: Wed Jun 23 2004 - 13:58:56 EST


On Wed, 23 Jun 2004 14:45:47 -0400 (EDT)
rahul b jain cs student <rbj2@xxxxxxxxxxxx> wrote:

> can anyone explain what is the difference between the following two pieces
> of code.
>
> 1. if (!pskb_may_pull(skb, sizeof(struct iphdr)))
> goto inhdr_error;
>
> iph = skb->nh.iph;
>
> 2. if (!pskb_may_pull(skb, iph->ihl*4))
> goto inhdr_error;
>
> iph = skb->nh.iph;

We can't dereference any of the iphdr fields (such as iph->ihl) until
we know that at least "sizeof(struct iphdr)" bytes are there first.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/