From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 3A267818FD for ; Mon, 2 Jan 2017 22:12:42 -0800 (PST) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga102.jf.intel.com with ESMTP; 02 Jan 2017 22:12:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.33,451,1477983600"; d="scan'208";a="48883613" Received: from jiaxinwu-mobl2.ccr.corp.intel.com ([10.239.196.61]) by fmsmga005.fm.intel.com with ESMTP; 02 Jan 2017 22:12:41 -0800 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Wu Jiaxin Date: Tue, 3 Jan 2017 14:12:37 +0800 Message-Id: <1483423958-71760-2-git-send-email-jiaxin.wu@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1483423958-71760-1-git-send-email-jiaxin.wu@intel.com> References: <1483423958-71760-1-git-send-email-jiaxin.wu@intel.com> Subject: [Patch 1/2] MdeModulePkg/Ip4Dxe: Fix the potential NULL pointer free X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Jan 2017 06:12:42 -0000 Ip4Config2SetDnsServer may cause ASSERT if the invalid DNS server address received. The issue is triggered by the NULL pointer(Tmp) free. Cc: Ye Ting Cc: Fu Siyuan Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Wu Jiaxin --- MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c index 88ead9d..131b03f 100644 --- a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c +++ b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.c @@ -1,9 +1,9 @@ /** @file The implementation of EFI IPv4 Configuration II Protocol. - Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
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 @@ -739,17 +739,21 @@ Ip4Config2SetDnsServerWorker ( CopyMem (&DnsAddress, NewDns + NewIndex, sizeof (IP4_ADDR)); if (IP4_IS_UNSPECIFIED (NTOHL (DnsAddress)) || IP4_IS_LOCAL_BROADCAST (NTOHL (DnsAddress))) { // // The dns server address must be unicast. // - FreePool (Tmp); + if (Tmp != NULL) { + FreePool (Tmp); + } return EFI_INVALID_PARAMETER; } for (Index1 = NewIndex + 1; Index1 < NewDnsCount; Index1++) { if (EFI_IP4_EQUAL (NewDns + NewIndex, NewDns + Index1)) { - FreePool (Tmp); + if (Tmp != NULL) { + FreePool (Tmp); + } return EFI_INVALID_PARAMETER; } } if (OneAdded) { -- 1.9.5.msysgit.1