From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web12.595.1572487274040919326 for ; Wed, 30 Oct 2019 19:01:14 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: dandan.bi@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2019 19:01:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,249,1569308400"; d="scan'208";a="199386235" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga007.fm.intel.com with ESMTP; 30 Oct 2019 19:01:12 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 30 Oct 2019 19:01:12 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.41]) with mapi id 14.03.0439.000; Thu, 31 Oct 2019 10:01:11 +0800 From: "Dandan Bi" To: "devel@edk2.groups.io" , "Zhang, Shenglei" CC: "Wang, Jian J" , "Wu, Hao A" Subject: Re: [edk2-devel] [PATCH v2 4/4] MdeModulePkg/SetupBrowserDxe: Add check for GetBufferForValue() Thread-Topic: [edk2-devel] [PATCH v2 4/4] MdeModulePkg/SetupBrowserDxe: Add check for GetBufferForValue() Thread-Index: AQHVjy4pz1v6NEK3lk2LxC2in0JEPqdz/Dlw Date: Thu, 31 Oct 2019 02:01:09 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB40C93533@SHSMSX104.ccr.corp.intel.com> References: <20191030142710.42756-1-shenglei.zhang@intel.com> <20191030142710.42756-5-shenglei.zhang@intel.com> In-Reply-To: <20191030142710.42756-5-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-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: dandan.bi@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable -----Original Message----- From: devel@edk2.groups.io On Behalf Of Zhang, Shen= glei Sent: Wednesday, October 30, 2019 10:27 PM To: devel@edk2.groups.io Cc: Wang, Jian J ; Wu, Hao A Subject: [edk2-devel] [PATCH v2 4/4] MdeModulePkg/SetupBrowserDxe: Add che= ck for GetBufferForValue() The returned value from GetBufferForValue might be NULL, so add a check fo= r that before it is used. Cc: Jian J Wang Cc: Hao A Wu Signed-off-by: Shenglei Zhang --- MdeModulePkg/Universal/SetupBrowserDxe/Expression.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModu= lePkg/Universal/SetupBrowserDxe/Expression.c index 7f4929c2fcd9..984c68c6bb7a 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -1281,7 +1281,12 @@ IfrToUint ( Result->Type =3D EFI_IFR_TYPE_UNDEFINED; return EFI_SUCCESS; } + + if (GetBufferForValue (&Value) =3D=3D NULL) { + return EFI_NOT_FOUND; + } Hi Shenglei, Before call GetBufferForValue function, has already called function IsTyp= eInBuffer to make sure the value must be buffer type. So GetBufferForValue can not return NULL.=20 I think we also can add ASSERT here. Thanks, Dandan Result->Value.u64 =3D *(UINT64*) GetBufferForValue (&Value); + if (Value.Type =3D=3D EFI_IFR_TYPE_BUFFER) { FreePool (Value.Buffer); } -- 2.18.0.windows.1