Skip to content

Commit

Permalink
[NET]: Do not dereference iov if length is zero
Browse files Browse the repository at this point in the history
When msg_iovlen is zero we shouldn't try to dereference
msg_iov.  Right now the only thing that tries to do so
is skb_copy_and_csum_datagram_iovec.  Since the total
length should also be zero if msg_iovlen is zero, it's
sufficient to check the total length there and simply
return if it's zero.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Sep 11, 2007
1 parent 2fbe43f commit ef8aef5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/core/datagram.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,9 @@ int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
__wsum csum;
int chunk = skb->len - hlen;

if (!chunk)
return 0;

/* Skip filled elements.
* Pretty silly, look at memcpy_toiovec, though 8)
*/
Expand Down

0 comments on commit ef8aef5

Please sign in to comment.