summaryrefslogtreecommitdiffstats
path: root/kernel/net/ipv4/ping.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/net/ipv4/ping.c')
-rw-r--r--kernel/net/ipv4/ping.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/net/ipv4/ping.c b/kernel/net/ipv4/ping.c
index aa67e0e64..3a00512ad 100644
--- a/kernel/net/ipv4/ping.c
+++ b/kernel/net/ipv4/ping.c
@@ -645,6 +645,8 @@ static int ping_v4_push_pending_frames(struct sock *sk, struct pingfakehdr *pfh,
{
struct sk_buff *skb = skb_peek(&sk->sk_write_queue);
+ if (!skb)
+ return 0;
pfh->wcheck = csum_partial((char *)&pfh->icmph,
sizeof(struct icmphdr), pfh->wcheck);
pfh->icmph.checksum = csum_fold(pfh->wcheck);
@@ -660,6 +662,10 @@ int ping_common_sendmsg(int family, struct msghdr *msg, size_t len,
if (len > 0xFFFF)
return -EMSGSIZE;
+ /* Must have at least a full ICMP header. */
+ if (len < icmph_len)
+ return -EINVAL;
+
/*
* Check the flags.
*/