* [Patch] MdeModulePkg/IpIoLib: return error instead of ASSERT if input parameter is incorrect.
@ 2017-12-13 6:43 Fu Siyuan
0 siblings, 0 replies; only message in thread
From: Fu Siyuan @ 2017-12-13 6:43 UTC (permalink / raw)
To: edk2-devel; +Cc: Ye Ting, Wu Jiaxin, Wang Fan
This patch updates the DxeIpIoLib to return EFI_INVALID_PARAMETER instead of
ASSERT if the input pointers are not correct.
Cc: Ye Ting <ting.ye@intel.com>
Cc: Wu Jiaxin <jiaxin.wu@intel.com>
Cc: Wang Fan <fan.wang@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Fu Siyuan <siyuan.fu@intel.com>
---
MdeModulePkg/Include/Library/IpIoLib.h | 24 +++++++++++++-----------
MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c | 12 ++++++++++--
2 files changed, 23 insertions(+), 13 deletions(-)
diff --git a/MdeModulePkg/Include/Library/IpIoLib.h b/MdeModulePkg/Include/Library/IpIoLib.h
index aab0c68059..0bebdb73b5 100644
--- a/MdeModulePkg/Include/Library/IpIoLib.h
+++ b/MdeModulePkg/Include/Library/IpIoLib.h
@@ -2,7 +2,7 @@
This library is only intended to be used by UEFI network stack modules.
It provides the combined IpIo layer on the EFI IP4 Protocol and EFI IP6 protocol.
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, 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 that accompanies this distribution.
The full text of the license may be found at
@@ -399,23 +399,25 @@ IpIoOpen (
Send out an IP packet.
This function is called after IpIoOpen(). The data to be sent are wrapped in
- Pkt. The IP instance wrapped in IpIo is used for sending by default, but can be
- overriden by Sender. Other sending configurations, such as source address and gateway
- address, are specified in OverrideData.
+ Pkt. The IP instance wrapped in IpIo is used for sending by default but can be
+ overriden by Sender. Other sending configs, like source address and gateway
+ address etc., are specified in OverrideData.
- @param[in, out] IpIo The pointer to an IP_IO instance used for sending IP
+ @param[in, out] IpIo Pointer to an IP_IO instance used for sending IP
packet.
- @param[in, out] Pkt The pointer to the IP packet to be sent.
- @param[in] Sender Optional. The IP protocol instance used for sending.
- @param[in] Context The optional context data.
- @param[in] NotifyData The optional notify data.
+ @param[in, out] Pkt Pointer to the IP packet to be sent.
+ @param[in] Sender The IP protocol instance used for sending.
+ @param[in] Context Optional context data.
+ @param[in] NotifyData Optional notify data.
@param[in] Dest The destination IP address to send this packet to.
+ This parameter is optional when using IPv6.
@param[in] OverrideData The data to override some configuration of the IP
instance used for sending.
- @retval EFI_SUCCESS The operation completed successfully.
+ @retval EFI_SUCCESS The operation is completed successfully.
+ @retval EFI_INVALID_PARAMETER The input parameter is not correct.
@retval EFI_NOT_STARTED The IpIo is not configured.
- @retval EFI_OUT_OF_RESOURCES Failed due to resource limitations.
+ @retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
**/
EFI_STATUS
diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
index abc07fb0ff..cd9bc3bd54 100644
--- a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
+++ b/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c
@@ -2,7 +2,7 @@
IpIo Library.
(C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 2017, 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
which accompanies this distribution. The full text of the license may be found at
@@ -1524,10 +1524,12 @@ IpIoDestroy (
@param[in] Context Optional context data.
@param[in] NotifyData Optional notify data.
@param[in] Dest The destination IP address to send this packet to.
+ This parameter is optional when using IPv6.
@param[in] OverrideData The data to override some configuration of the IP
instance used for sending.
@retval EFI_SUCCESS The operation is completed successfully.
+ @retval EFI_INVALID_PARAMETER The input parameter is not correct.
@retval EFI_NOT_STARTED The IpIo is not configured.
@retval EFI_OUT_OF_RESOURCES Failed due to resource limit.
@@ -1548,7 +1550,13 @@ IpIoSend (
IP_IO_IP_PROTOCOL Ip;
IP_IO_SEND_ENTRY *SndEntry;
- ASSERT ((IpIo->IpVersion != IP_VERSION_4) || (Dest != NULL));
+ if ((IpIo == NULL) || (Pkt == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((IpIo->IpVersion == IP_VERSION_4) && (Dest == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
if (!IpIo->IsConfigured) {
return EFI_NOT_STARTED;
--
2.13.0.windows.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-12-13 6:39 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-13 6:43 [Patch] MdeModulePkg/IpIoLib: return error instead of ASSERT if input parameter is incorrect Fu Siyuan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox