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.782.1571034947691994233 for ; Sun, 13 Oct 2019 23:35:47 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: zhichao.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Oct 2019 23:35:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,294,1566889200"; d="scan'208";a="207909511" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga001.fm.intel.com with ESMTP; 13 Oct 2019 23:35:46 -0700 Received: from fmsmsx118.amr.corp.intel.com (10.18.116.18) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 13 Oct 2019 23:35:46 -0700 Received: from shsmsx108.ccr.corp.intel.com (10.239.4.97) by fmsmsx118.amr.corp.intel.com (10.18.116.18) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 13 Oct 2019 23:35:46 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.96]) by SHSMSX108.ccr.corp.intel.com ([169.254.8.225]) with mapi id 14.03.0439.000; Mon, 14 Oct 2019 14:35:44 +0800 From: "Gao, Zhichao" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Ni, Ray" Subject: Re: [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer Thread-Topic: [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->Buffer Thread-Index: AQHVgi47NWEt91wsoU6mUPbAJITIhqdZrPgQ Date: Mon, 14 Oct 2019 06:35:43 +0000 Message-ID: <3CE959C139B4C44DBEA1810E3AA6F9000B8565FD@SHSMSX101.ccr.corp.intel.com> References: <20191014012511.860-1-shenglei.zhang@intel.com> In-Reply-To: <20191014012511.860-1-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Return-Path: zhichao.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Refer to CSS 5.2.2.6 Always put space before an open parenthesis. FreePool(AsciiBuffer); should be FreePool (AsciiBuffer); After address that, Reviewed-by: Zhichao Gao Thanks, Zhichao > -----Original Message----- > From: Zhang, Shenglei > Sent: Monday, October 14, 2019 9:25 AM > To: devel@edk2.groups.io > Cc: Ni, Ray ; Gao, Zhichao > Subject: [PATCH v2] ShellPkg/Shell/FileHandleWrappers.c: Add check for > MemFile->Buffer >=20 > Add check for MemFile->Buffer. > Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL. >=20 > Cc: Ray Ni > Cc: Zhichao Gao > Signed-off-by: Shenglei Zhang > --- >=20 > v2: Add the expressiong to free AsciiBuffer before the function is return= ed. >=20 > ShellPkg/Application/Shell/FileHandleWrappers.c | 7 +++++++ > 1 file changed, 7 insertions(+) >=20 > diff --git a/ShellPkg/Application/Shell/FileHandleWrappers.c > b/ShellPkg/Application/Shell/FileHandleWrappers.c > index 587556c42495..2d7bd7bec67e 100644 > --- a/ShellPkg/Application/Shell/FileHandleWrappers.c > +++ b/ShellPkg/Application/Shell/FileHandleWrappers.c > @@ -1644,6 +1644,9 @@ FileInterfaceMemWrite( > // > if ((UINTN)(MemFile->Position + (*BufferSize)) > (UINTN)(MemFile- > >BufferSize)) { > MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize), > (UINTN)(MemFile->BufferSize) + (*BufferSize) + > MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer); > + if (MemFile->Buffer =3D=3D NULL){ > + return EFI_OUT_OF_RESOURCES; > + } > MemFile->BufferSize +=3D (*BufferSize) + > MEM_WRITE_REALLOC_OVERHEAD; > } > CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, Buffer, > *BufferSize); @@ -1661,6 +1664,10 @@ FileInterfaceMemWrite( > AsciiSPrint(AsciiBuffer, *BufferSize, "%S", Buffer); > if ((UINTN)(MemFile->Position + AsciiStrSize(AsciiBuffer)) > > (UINTN)(MemFile->BufferSize)) { > MemFile->Buffer =3D ReallocatePool((UINTN)(MemFile->BufferSize), > (UINTN)(MemFile->BufferSize) + AsciiStrSize(AsciiBuffer) + > MEM_WRITE_REALLOC_OVERHEAD, MemFile->Buffer); > + if (MemFile->Buffer =3D=3D NULL){ > + FreePool(AsciiBuffer); > + return EFI_OUT_OF_RESOURCES; > + } > MemFile->BufferSize +=3D AsciiStrSize(AsciiBuffer) + > MEM_WRITE_REALLOC_OVERHEAD; > } > CopyMem(((UINT8*)MemFile->Buffer) + MemFile->Position, AsciiBuffer, > AsciiStrSize(AsciiBuffer)); > -- > 2.18.0.windows.1