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.20; helo=mga02.intel.com; envelope-from=jiaxin.wu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (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 601002115993D for ; Thu, 27 Sep 2018 07:44:06 -0700 (PDT) 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; 27 Sep 2018 07:44:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,311,1534834800"; d="scan'208";a="73450991" Received: from kkochumm-mobl.gar.corp.intel.com (HELO jiaxinwu-MOBL.ccr.corp.intel.com) ([10.255.133.39]) by fmsmga007.fm.intel.com with ESMTP; 27 Sep 2018 07:43:08 -0700 From: Jiaxin Wu To: edk2-devel@lists.01.org Cc: Ye Ting , Fu Siyuan , Carsey Jaben , Zeng Star , Wu Jiaxin Date: Thu, 27 Sep 2018 22:42:03 +0800 Message-Id: <20180927144203.576-1-Jiaxin.wu@intel.com> X-Mailer: git-send-email 2.17.1.windows.2 Subject: [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: Thu, 27 Sep 2018 14:44:06 -0000 Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1217 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/DynamicCommand/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]; + 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 = FileSize; TftpContext->DownloadedNbOfBytes = 0; TftpContext->LastReportedNbOfBytes = 0; - ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN)); Mtftp4Token.Filename = (UINT8*)AsciiFilePath; Mtftp4Token.BufferSize = FileSize; Mtftp4Token.Buffer = Buffer; Mtftp4Token.CheckPacket = CheckPacket; Mtftp4Token.Context = (VOID*)TftpContext; -- 2.17.1.windows.2