From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (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 A49EE21159CA3 for ; Thu, 27 Sep 2018 19:36:12 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Sep 2018 19:36:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,313,1534834800"; d="scan'208";a="87403907" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga003.jf.intel.com with ESMTP; 27 Sep 2018 19:30:34 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 19:30:34 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 27 Sep 2018 19:30:34 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.140]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.245]) with mapi id 14.03.0319.002; Fri, 28 Sep 2018 10:30:31 +0800 From: "Zeng, Star" To: "Wu, Jiaxin" , "edk2-devel@lists.01.org" CC: "Ye, Ting" , "Fu, Siyuan" , "Carsey, Jaben" , "Zeng, Star" Thread-Topic: [Patch] ShellPkg/TftpDynamicCommand: Fix the potentially uninitialized local variable used. Thread-Index: AQHUVnCPskaZWpXMOUGm8MdMvW727aUE+X8A Date: Fri, 28 Sep 2018 02:30:30 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BBF4697@shsmsx102.ccr.corp.intel.com> References: <20180927144203.576-1-Jiaxin.wu@intel.com> In-Reply-To: <20180927144203.576-1-Jiaxin.wu@intel.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] ShellPkg/TftpDynamicCommand: Fix the potentially uninitialized local variable used. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2018 02:36:12 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng -----Original Message----- From: Wu, Jiaxin=20 Sent: Thursday, September 27, 2018 10:42 PM To: edk2-devel@lists.01.org Cc: Ye, Ting ; Fu, Siyuan ; Carsey,= Jaben ; Zeng, Star ; Wu, Jiax= in Subject: [Patch] ShellPkg/TftpDynamicCommand: Fix the potentially uninitial= ized local variable used. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1217 Local variable 'Mtftp4Token' might be uninitialized when error happen. This= patch is to resolve the issue. Cc: Ye Ting Cc: Fu Siyuan Cc: Carsey Jaben Cc: Zeng Star Contributed-under: TianoCore Contribution Agreement 1.1 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/D= ynamicCommand/TftpDynamicCommand/Tftp.c index c66be6b9d9..d4391b9f33 100644 --- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c +++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c @@ -934,10 +934,12 @@ DownloadFile ( DOWNLOAD_CONTEXT *TftpContext; EFI_MTFTP4_TOKEN Mtftp4Token; UINT8 BlksizeBuf[10]; UINT8 WindowsizeBuf[10]; =20 + ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN)); + // Downloaded file can be large. BS.AllocatePages() is more faster // than AllocatePool() and avoid fragmentation. // The downloaded file could be an EFI application. Marking the // allocated page as EfiBootServicesCode would allow to execute a // potential downloaded EFI application. @@ -959,11 +961,10 @@ DownloadFile ( } TftpContext->FileSize =3D FileSize; TftpContext->DownloadedNbOfBytes =3D 0; TftpContext->LastReportedNbOfBytes =3D 0; =20 - ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN)); Mtftp4Token.Filename =3D (UINT8*)AsciiFilePath; Mtftp4Token.BufferSize =3D FileSize; Mtftp4Token.Buffer =3D Buffer; Mtftp4Token.CheckPacket =3D CheckPacket; Mtftp4Token.Context =3D (VOID*)TftpContext; -- 2.17.1.windows.2