From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by groups.io with SMTP; Thu, 12 Sep 2019 11:54:56 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2019 11:54:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,492,1559545200"; d="scan'208";a="176053020" Received: from orsmsx110.amr.corp.intel.com ([10.22.240.8]) by orsmga007.jf.intel.com with ESMTP; 12 Sep 2019 11:54:55 -0700 Received: from orsmsx113.amr.corp.intel.com (10.22.240.9) by ORSMSX110.amr.corp.intel.com (10.22.240.8) with Microsoft SMTP Server (TLS) id 14.3.439.0; Thu, 12 Sep 2019 11:54:55 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.225]) by ORSMSX113.amr.corp.intel.com ([169.254.9.17]) with mapi id 14.03.0439.000; Thu, 12 Sep 2019 11:54:55 -0700 From: "Nate DeSimone" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Kubacki, Michael A" , "Chiu, Chasel" , "Gao, Liming" Subject: Re: [PATCH] MinPlatformPkg/TestPointCheckLib: Add check for pointers Thread-Topic: [PATCH] MinPlatformPkg/TestPointCheckLib: Add check for pointers Thread-Index: AQHVaRV0kn3ItU3EP0CFm/kIatT4h6coZJpg Date: Thu, 12 Sep 2019 18:54:54 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEEB44BF@ORSMSX114.amr.corp.intel.com> References: <20190912025442.36436-1-shenglei.zhang@intel.com> In-Reply-To: <20190912025442.36436-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMWRhM2M4YmMtMDg1NS00MTQwLTkyMGEtOGUwYzZlMWE5ZmFlIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOFdTNWZ2bmd2K1wvRG5vYndKRUVBMU5HenpzVENQZEJkeWhMMmxuWUdWWEIyUG84U2xXVkxQb1wvK0dcL1FNT0VnYSJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Your whitespace doesn't quite match the edk2 coding style guidelines, but w= e can fix that during commit. Reviewed-by: Nate DeSimone -----Original Message----- From: Zhang, Shenglei=20 Sent: Wednesday, September 11, 2019 7:55 PM To: devel@edk2.groups.io Cc: Kubacki, Michael A ; Chiu, Chasel ; Desimone, Nathaniel L ; Ga= o, Liming Subject: [PATCH] MinPlatformPkg/TestPointCheckLib: Add check for pointers In DxeCheckBootVariable.c, add check for BootOrder and Variable that return= EFI_NOT_FOUND when they are NULL. In DxeCheckGcd.c, add check for GcdIoMap to ensure it not NULL when allocat= ing memory to what it points to. Cc: Michael Kubacki Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Shenglei Zhang --- v2: Update copyright .../Test/Library/TestPointCheckLib/DxeCheckBootVariable.c | 8 +++++++- .../Test/Library/TestPointCheckLib/DxeCheckGcd.c | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeCheckBootVariable.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPoin= tCheckLib/DxeCheckBootVariable.c index 85bd5b3d..98130683 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= BootVariable.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh +++ eckBootVariable.c @@ -1,6 +1,6 @@ /** @file =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -130,6 +130,9 @@ TestPointCheckLoadOptionVariable ( for (ListIndex =3D 0; ListIndex < sizeof(mLoadOptionVariableList)/sizeof= (mLoadOptionVariableList[0]); ListIndex++) { UnicodeSPrint (BootOrderName, sizeof(BootOrderName), L"%sOrder", mLoad= OptionVariableList[ListIndex]); Status =3D GetVariable2 (BootOrderName, &gEfiGlobalVariableGuid, (VOID= **)&BootOrder, &OrderSize); + if(BootOrder =3D=3D NULL) { + return EFI_NOT_FOUND;; + } if (EFI_ERROR(Status)) { continue; } @@ -222,6 +225,9 @@ TestPointCheckKeyOptionVariable ( for (Index =3D 0; ; Index++) { UnicodeSPrint (KeyOptionName, sizeof(KeyOptionName), L"%s%04x", mKey= OptionVariableList[ListIndex], Index); Status =3D GetVariable2 (KeyOptionName, &gEfiGlobalVariableGuid, &Va= riable, &Size); + if(Variable =3D=3D NULL) { + return EFI_NOT_FOUND;; + } if (!EFI_ERROR(Status)) { DumpKeyOption (KeyOptionName, Variable, Size); } else { diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/D= xeCheckGcd.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib= /DxeCheckGcd.c index 82709d44..c90b37f2 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheck= Gcd.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCh +++ eckGcd.c @@ -1,6 +1,6 @@ /** @file =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -241,7 +241,9 @@ TestPointDumpGcd ( } } if (GcdMemoryMap !=3D NULL) { - *GcdIoMap =3D AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_GCD= _IO_SPACE_DESCRIPTOR), IoMap); + if (GcdIoMap !=3D NULL){ + *GcdIoMap =3D AllocateCopyPool (NumberOfDescriptors * sizeof(EFI_G= CD_IO_SPACE_DESCRIPTOR), IoMap); + } *GcdIoMapNumberOfDescriptors =3D NumberOfDescriptors; } } -- 2.18.0.windows.1