From: Jiaxin Wu Date: Thu, 27 Sep 2018 10:43:23 +0000 (+0800) Subject: ShellPkg/TftpDynamicCommand: Fix the potentially uninitialized local variable used. X-Git-Tag: edk2-stable201903~928 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=61d3f1000eaad4f359f1a949c2de2217241344d9;p=mirror_edk2.git ShellPkg/TftpDynamicCommand: Fix the potentially uninitialized local variable used. 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 Reviewed-by: Star Zeng --- 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 @@ -936,6 +936,8 @@ DownloadFile ( 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 @@ -961,7 +963,6 @@ DownloadFile ( TftpContext->DownloadedNbOfBytes = 0; TftpContext->LastReportedNbOfBytes = 0; - ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN)); Mtftp4Token.Filename = (UINT8*)AsciiFilePath; Mtftp4Token.BufferSize = FileSize; Mtftp4Token.Buffer = Buffer;