From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.100; helo=mga07.intel.com; envelope-from=jaben.carsey@intel.com; receiver=edk2-devel@lists.01.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (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 97C2C20972140 for ; Thu, 12 Jul 2018 08:45:29 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Jul 2018 08:45:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,343,1526367600"; d="scan'208";a="70844944" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga004.fm.intel.com with ESMTP; 12 Jul 2018 08:45:01 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 12 Jul 2018 08:45:00 -0700 Received: from fmsmsx103.amr.corp.intel.com ([169.254.2.106]) by FMSMSX109.amr.corp.intel.com ([169.254.15.66]) with mapi id 14.03.0319.002; Thu, 12 Jul 2018 08:45:00 -0700 From: "Carsey, Jaben" To: "Fu, Siyuan" , "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" Thread-Topic: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue. Thread-Index: AQHUGXl7LLVTeem1HUul2Ruk76D+S6SLNcyAgACF0IA= Date: Thu, 12 Jul 2018 15:45:00 +0000 Message-ID: References: <20180712004410.13324-1-Jiaxin.wu@intel.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNzg5MzE1YjUtZDI1Ni00NzZhLTg3N2QtYmZlODZhNTM2ZWFkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUHBVY2M4RU9YOWd5cEdSOWhIcDQxTmswXC95b1lvQnNyOTZycjVRQ3U1TFZkZWM1bHpVVTdlU0tjWllaN1wvN2RHIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.200.100 dlp-reaction: no-action x-originating-ip: [10.1.200.107] MIME-Version: 1.0 Subject: Re: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Jul 2018 15:45:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Jaben Carsey > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, July 11, 2018 5:46 PM > To: Wu, Jiaxin ; edk2-devel@lists.01.org > Cc: Ye, Ting ; Carsey, Jaben > Subject: RE: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential > assertion and memory leak issue. > Importance: High >=20 >=20 >=20 > Reviewed-by: Fu Siyuan >=20 > > -----Original Message----- > > From: Wu, Jiaxin > > Sent: Thursday, July 12, 2018 8:44 AM > > To: edk2-devel@lists.01.org > > Cc: Wu, Jiaxin ; Ye, Ting ; Fu, > > Siyuan ; Carsey, Jaben > > Subject: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential > assertion > > and memory leak issue. > > > > From: Jiaxin Wu > > > > This patch is to fix the issue reported from > > https://bugzilla.tianocore.org/show_bug.cgi?id=3D925. > > > > DataSize variable was not assigned the value if ShellOpenFileByName > > returns error. > > In the such a case, it should not be used to FreePages. Instead, DataSi= ze > > can be > > used to record the file size once DownloadFile successfully. > > > > Cc: Ye Ting > > Cc: Fu Siyuan > > Cc: Jaben Carsey > > Contributed-under: TianoCore Contribution Agreement 1.0 > > Signed-off-by: Wu Jiaxin > > --- > > ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > > b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > > index e2491cd54c..44be6d4e76 100644 > > --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > > +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c > > @@ -517,10 +517,12 @@ RunTftp ( > > mTftpHiiHandle, RemoteFilePath, NicName, Status > > ); > > goto NextHandle; > > } > > > > + DataSize =3D FileSize; > > + > > if (!EFI_ERROR (ShellFileExists (LocalFilePath))) { > > ShellDeleteFileByName (LocalFilePath); > > } > > > > Status =3D ShellOpenFileByName ( > > @@ -537,11 +539,10 @@ RunTftp ( > > mTftpHiiHandle, L"tftp", LocalFilePath > > ); > > goto NextHandle; > > } > > > > - DataSize =3D FileSize; > > Status =3D ShellWriteFile (FileHandle, &FileSize, Data); > > if (!EFI_ERROR (Status)) { > > ShellStatus =3D SHELL_SUCCESS; > > } else { > > ShellPrintHiiEx ( > > -- > > 2.17.1.windows.2