From nobody Tue Dec 24 02:03:15 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 1515036059155852.8780446109927; Wed, 3 Jan 2018 19:20:59 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id C541C222D1547; Wed, 3 Jan 2018 19:15:53 -0800 (PST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 CFFC422280C5B for ; Wed, 3 Jan 2018 19:15:51 -0800 (PST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2018 19:20:23 -0800 Received: from fanwang2-hp.ccr.corp.intel.com ([10.239.9.33]) by orsmga001.jf.intel.com with ESMTP; 03 Jan 2018 19:20:22 -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: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=fan.wang@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,505,1508828400"; d="scan'208";a="21245822" From: fanwang2 To: edk2-devel@lists.01.org Date: Thu, 4 Jan 2018 11:20:05 +0800 Message-Id: <1515036008-10700-2-git-send-email-fan.wang@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1515036008-10700-1-git-send-email-fan.wang@intel.com> References: <1515036008-10700-1-git-send-email-fan.wang@intel.com> Subject: [edk2] [Patch 1/4] NetworkPkg: Add ASSERT error handling for UDP6 driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ye Ting , Wang Fan , Fu Siyuan , Jiaxin Wu 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" From: Wang Fan 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 Cc: Jiaxin Wu Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wang Fan --- NetworkPkg/Udp6Dxe/Udp6Impl.c | 16 +++++++++++++++- NetworkPkg/Udp6Dxe/Udp6Main.c | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/NetworkPkg/Udp6Dxe/Udp6Impl.c b/NetworkPkg/Udp6Dxe/Udp6Impl.c index edf2c23..25d4e6a 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Impl.c +++ b/NetworkPkg/Udp6Dxe/Udp6Impl.c @@ -1,9 +1,9 @@ /** @file Udp6 driver's whole implementation. =20 - Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -1606,10 +1606,14 @@ Udp6Demultiplex ( // // Get the datagram header from the packet buffer. // Udp6Header =3D (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + NetbufFree (Packet); + return; + } =20 if (Udp6Header->Checksum !=3D 0) { // // check the checksum. // @@ -1716,10 +1720,13 @@ Udp6SendPortUnreach ( // // Get the Ipv6 Mode Data. // Ip6ModeData =3D AllocateZeroPool (sizeof (EFI_IP6_MODE_DATA)); ASSERT (Ip6ModeData !=3D NULL); + if (Ip6ModeData =3D=3D NULL) { + goto EXIT; + } =20 // // If not finding the related IpSender use the default IpIo to send out // the port unreachable ICMP message. // @@ -1764,10 +1771,13 @@ Udp6SendPortUnreach ( // // Allocate space for the IP6_ICMP_ERROR_HEAD. // IcmpErrHdr =3D (IP6_ICMP_ERROR_HEAD *) NetbufAllocSpace (Packet, Len, FA= LSE); ASSERT (IcmpErrHdr !=3D NULL); + if (IcmpErrHdr =3D=3D NULL) { + goto EXIT; + } =20 // // Set the required fields for the icmp port unreachable message. // IcmpErrHdr->Head.Type =3D ICMP_V6_DEST_UNREACHABLE; @@ -1845,10 +1855,14 @@ Udp6IcmpHandler ( return; } =20 Udp6Header =3D (EFI_UDP_HEADER *) NetbufGetByte (Packet, 0, NULL); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + NetbufFree (Packet); + return; + } =20 IP6_COPY_ADDRESS (&Udp6Session.SourceAddress, &NetSession->Source); IP6_COPY_ADDRESS (&Udp6Session.DestinationAddress, &NetSession->Dest); =20 Udp6Session.SourcePort =3D NTOHS (Udp6Header->DstPort); diff --git a/NetworkPkg/Udp6Dxe/Udp6Main.c b/NetworkPkg/Udp6Dxe/Udp6Main.c index f3e9925..9105ef4 100644 --- a/NetworkPkg/Udp6Dxe/Udp6Main.c +++ b/NetworkPkg/Udp6Dxe/Udp6Main.c @@ -1,9 +1,9 @@ /** @file Contains all EFI_UDP6_PROTOCOL interfaces. =20 - Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
=20 This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at http://opensource.org/licenses/bsd-license.php. @@ -523,10 +523,15 @@ Udp6Transmit ( Udp6Service =3D Instance->Udp6Service; *((UINTN *) &Packet->ProtoData[0]) =3D (UINTN) (Udp6Service->IpIo); =20 Udp6Header =3D (EFI_UDP_HEADER *) NetbufAllocSpace (Packet, UDP6_HEADER_= SIZE, TRUE); ASSERT (Udp6Header !=3D NULL); + if (Udp6Header =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto ON_EXIT; + } + =20 ConfigData =3D &Instance->ConfigData; =20 // // Fill the udp header. // --=20 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel