From nobody Mon Apr 29 00:55:28 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1513147441264688.4186007925902; Tue, 12 Dec 2017 22:44:01 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A1B4E2214E345; Tue, 12 Dec 2017 22:39:20 -0800 (PST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id ABDDF2214E322 for ; Tue, 12 Dec 2017 22:39:19 -0800 (PST) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2017 22:43:58 -0800 Received: from sfu5-mobl.ccr.corp.intel.com ([10.239.192.226]) by orsmga003.jf.intel.com with ESMTP; 12 Dec 2017 22:43:56 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Permerror (SPF Permanent Error: More than 10 MX records returned) identity=mailfrom; client-ip=192.55.52.115; helo=mga14.intel.com; envelope-from=siyuan.fu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,397,1508828400"; d="scan'208";a="11887000" From: Fu Siyuan To: edk2-devel@lists.01.org Date: Wed, 13 Dec 2017 14:43:53 +0800 Message-Id: <20171213064353.8468-1-siyuan.fu@intel.com> X-Mailer: git-send-email 2.13.0.windows.1 Subject: [edk2] [Patch] MdeModulePkg/IpIoLib: return error instead of ASSERT if input parameter is incorrect. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Wu Jiaxin MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch updates the DxeIpIoLib to return EFI_INVALID_PARAMETER instead of ASSERT if the input pointers are not correct. Cc: Ye Ting Cc: Wu Jiaxin Cc: Wang Fan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan --- 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. =20 -Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made availabl= e under=20 the terms and conditions of the BSD License that accompanies this distribu= tion. =20 The full text of the license may be found at @@ -399,23 +399,25 @@ IpIoOpen ( Send out an IP packet. =20 This function is called after IpIoOpen(). The data to be sent are wrappe= d 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 addres= s 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 gate= way + address etc., are specified in OverrideData. =20 - @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 b= e sent. - @param[in] Sender Optional. The IP protocol instanc= e 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 se= nt. + @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 sen= d this packet to. + This parameter is optional when u= sing IPv6. @param[in] OverrideData The data to override some configu= ration of the IP instance used for sending. =20 - @retval EFI_SUCCESS The operation completed successfu= lly. + @retval EFI_SUCCESS The operation is completed succes= sfully. + @retval EFI_INVALID_PARAMETER The input parameter is not correc= t. @retval EFI_NOT_STARTED The IpIo is not configured. - @retval EFI_OUT_OF_RESOURCES Failed due to resource limitation= s. + @retval EFI_OUT_OF_RESOURCES Failed due to resource limit. =20 **/ EFI_STATUS diff --git a/MdeModulePkg/Library/DxeIpIoLib/DxeIpIoLib.c b/MdeModulePkg/Li= brary/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. =20 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
-Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2017, Intel Corporation. All rights reserved.
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 sen= d this packet to. + This parameter is optional when u= sing IPv6. @param[in] OverrideData The data to override some configu= ration of the IP instance used for sending. =20 @retval EFI_SUCCESS The operation is completed succes= sfully. + @retval EFI_INVALID_PARAMETER The input parameter is not correc= t. @retval EFI_NOT_STARTED The IpIo is not configured. @retval EFI_OUT_OF_RESOURCES Failed due to resource limit. =20 @@ -1548,7 +1550,13 @@ IpIoSend ( IP_IO_IP_PROTOCOL Ip; IP_IO_SEND_ENTRY *SndEntry; =20 - ASSERT ((IpIo->IpVersion !=3D IP_VERSION_4) || (Dest !=3D NULL)); + if ((IpIo =3D=3D NULL) || (Pkt =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } + + if ((IpIo->IpVersion =3D=3D IP_VERSION_4) && (Dest =3D=3D NULL)) { + return EFI_INVALID_PARAMETER; + } =20 if (!IpIo->IsConfigured) { return EFI_NOT_STARTED; --=20 2.13.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel