NetworkPkg: Add ASSERT error handling for UDP6 driver

In Udp6Dxe, there are several places use ASSERT to check returned
value. But these errors should be handled if they occur, this patch
is to fix this issue.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wang Fan <fan.wang@intel.com>
Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>
This commit is contained in:
Wang Fan 2018-01-03 17:30:54 +08:00 committed by Fu Siyuan
parent 0e8a782922
commit 2c4a45b361
2 changed files with 21 additions and 2 deletions

View File

@ -1,7 +1,7 @@
/** @file
Udp6 driver's whole implementation.
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -1608,6 +1608,10 @@ Udp6Demultiplex (
//
Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
ASSERT (Udp6Header != NULL);
if (Udp6Header == NULL) {
NetbufFree (Packet);
return;
}
if (Udp6Header->Checksum != 0) {
//
@ -1718,6 +1722,9 @@ Udp6SendPortUnreach (
//
Ip6ModeData = AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA));
ASSERT (Ip6ModeData != NULL);
if (Ip6ModeData == NULL) {
goto EXIT;
}
//
// If not finding the related IpSender use the default IpIo to send out
@ -1766,6 +1773,9 @@ Udp6SendPortUnreach (
//
IcmpErrHdr = (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FALSE);
ASSERT (IcmpErrHdr != NULL);
if (IcmpErrHdr == NULL) {
goto EXIT;
}
//
// Set the required fields for the icmp port unreachable message.
@ -1847,6 +1857,10 @@ Udp6IcmpHandler (
Udp6Header = (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL);
ASSERT (Udp6Header != NULL);
if (Udp6Header == NULL) {
NetbufFree (Packet);
return;
}
IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source);
IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest);

View File

@ -1,7 +1,7 @@
/** @file
Contains all EFI_UDP6_PROTOCOL interfaces.
Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -525,6 +525,11 @@ Udp6Transmit (
Udp6Header = (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_SIZE, TRUE);
ASSERT (Udp6Header != NULL);
if (Udp6Header == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto ON_EXIT;
}
ConfigData = &Instance->ConfigData;
//