]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/TftpDynamicCommand: Fix the potentially uninitialized local variable used.
authorJiaxin Wu <Jiaxin.wu@intel.com>
Thu, 27 Sep 2018 10:43:23 +0000 (18:43 +0800)
committerJiaxin Wu <Jiaxin.wu@intel.com>
Fri, 28 Sep 2018 02:46:28 +0000 (10:46 +0800)
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 <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Carsey Jaben <jaben.carsey@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c

index c66be6b9d97e5eb001373be22f08d813f5e6b7d5..d4391b9f33cd27adff0925ffec755aaf2da34740 100644 (file)
@@ -936,6 +936,8 @@ DownloadFile (
   UINT8                 BlksizeBuf[10];\r
   UINT8                 WindowsizeBuf[10];\r
 \r
+  ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));\r
+\r
   // Downloaded file can be large. BS.AllocatePages() is more faster\r
   // than AllocatePool() and avoid fragmentation.\r
   // The downloaded file could be an EFI application. Marking the\r
@@ -961,7 +963,6 @@ DownloadFile (
   TftpContext->DownloadedNbOfBytes   = 0;\r
   TftpContext->LastReportedNbOfBytes = 0;\r
 \r
-  ZeroMem (&Mtftp4Token, sizeof (EFI_MTFTP4_TOKEN));\r
   Mtftp4Token.Filename    = (UINT8*)AsciiFilePath;\r
   Mtftp4Token.BufferSize  = FileSize;\r
   Mtftp4Token.Buffer      = Buffer;\r