]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue.
authorJiaxin Wu <jiaxin.wu@intel.com>
Thu, 26 Apr 2018 06:13:57 +0000 (14:13 +0800)
committerJiaxin Wu <Jiaxin.wu@intel.com>
Fri, 13 Jul 2018 05:45:04 +0000 (13:45 +0800)
This patch is to fix the issue reported from
https://bugzilla.tianocore.org/show_bug.cgi?id=925.

DataSize variable was not assigned the value if ShellOpenFileByName returns error.
In the such a case, it should not be used to FreePages. Instead, DataSize can be
used to record the file size once DownloadFile successfully.

Cc: Ye Ting <ting.ye@intel.com>
Cc: Fu Siyuan <siyuan.fu@intel.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin <jiaxin.wu@intel.com>
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c

index e2491cd54cae5b5e970cb020bd8c3aed1493e121..44be6d4e76f4bd754b007ba00d024797664a684f 100644 (file)
@@ -519,6 +519,8 @@ RunTftp (
       goto NextHandle;\r
     }\r
 \r
+    DataSize = FileSize;\r
+\r
     if (!EFI_ERROR (ShellFileExists (LocalFilePath))) {\r
       ShellDeleteFileByName (LocalFilePath);\r
     }\r
@@ -539,7 +541,6 @@ RunTftp (
       goto NextHandle;\r
     }\r
 \r
-    DataSize = FileSize;\r
     Status = ShellWriteFile (FileHandle, &FileSize, Data);\r
     if (!EFI_ERROR (Status)) {\r
       ShellStatus = SHELL_SUCCESS;\r