8c6b1ac71e
Also include some minor fixes for gcc 5.1.1 Signed-off-by: Peter Jones <pjones@redhat.com>
60 lines
1.9 KiB
Diff
60 lines
1.9 KiB
Diff
From b40fde29a446d9fa5a6ebea7aafb34e3c958afbb Mon Sep 17 00:00:00 2001
|
|
From: Andrei Borzenkov <arvidjaar@gmail.com>
|
|
Date: Fri, 30 Jan 2015 22:09:51 +0300
|
|
Subject: [PATCH 276/506] net/ip: check result of grub_netbuff_push
|
|
|
|
Found by: Coverity scan.
|
|
---
|
|
grub-core/net/ip.c | 14 ++++++++++----
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/grub-core/net/ip.c b/grub-core/net/ip.c
|
|
index 5a60954..8c56baa 100644
|
|
--- a/grub-core/net/ip.c
|
|
+++ b/grub-core/net/ip.c
|
|
@@ -191,15 +191,18 @@ grub_net_send_ip4_packet (struct grub_net_network_level_interface *inf,
|
|
grub_net_ip_protocol_t proto)
|
|
{
|
|
struct iphdr *iph;
|
|
+ grub_err_t err;
|
|
|
|
COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV4_HEADER_SIZE == sizeof (*iph));
|
|
|
|
if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu)
|
|
return send_fragmented (inf, target, nb, proto, *ll_target_addr);
|
|
|
|
- grub_netbuff_push (nb, sizeof (*iph));
|
|
- iph = (struct iphdr *) nb->data;
|
|
+ err = grub_netbuff_push (nb, sizeof (*iph));
|
|
+ if (err)
|
|
+ return err;
|
|
|
|
+ iph = (struct iphdr *) nb->data;
|
|
iph->verhdrlen = ((4 << 4) | 5);
|
|
iph->service = 0;
|
|
iph->len = grub_cpu_to_be16 (nb->tail - nb->data);
|
|
@@ -602,15 +605,18 @@ grub_net_send_ip6_packet (struct grub_net_network_level_interface *inf,
|
|
grub_net_ip_protocol_t proto)
|
|
{
|
|
struct ip6hdr *iph;
|
|
+ grub_err_t err;
|
|
|
|
COMPILE_TIME_ASSERT (GRUB_NET_OUR_IPV6_HEADER_SIZE == sizeof (*iph));
|
|
|
|
if (nb->tail - nb->data + sizeof (struct iphdr) > inf->card->mtu)
|
|
return grub_error (GRUB_ERR_NET_PACKET_TOO_BIG, "packet too big");
|
|
|
|
- grub_netbuff_push (nb, sizeof (*iph));
|
|
- iph = (struct ip6hdr *) nb->data;
|
|
+ err = grub_netbuff_push (nb, sizeof (*iph));
|
|
+ if (err)
|
|
+ return err;
|
|
|
|
+ iph = (struct ip6hdr *) nb->data;
|
|
iph->version_class_flow = grub_cpu_to_be32_compile_time ((6 << 28));
|
|
iph->len = grub_cpu_to_be16 (nb->tail - nb->data - sizeof (*iph));
|
|
iph->protocol = proto;
|
|
--
|
|
2.4.3
|
|
|