]> git.proxmox.com Git - mirror_edk2.git/commitdiff
TFTP : tftp fix for full volume case
authorMeenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Mon, 25 Sep 2017 14:35:11 +0000 (20:05 +0530)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 24 Oct 2017 05:48:48 +0000 (13:48 +0800)
Issue :
When storage media is full, tftp was resulting in ASSERT
MdeModulePkg/Core/Dxe/Mem/Page.c, because number of pages
was zero.

Reason:
While doing tftp, function call ShellWriteFile was modifying
FileSize variable. In case of full disk it was coming out to be
Zero.

Fix:
Storage the original filesize in local variable, and use this
variable while freeing the pages.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
Signed-off-by: Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>
Signed-off-by: Vabhav Sharma <vabhav.sharma@nxp.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c

index 5c50797631f2886c0024d1fb30297dd4a275e59f..fbde3bfe6048f50beb2e4c7be8d188737ccd5916 100755 (executable)
@@ -284,6 +284,7 @@ ShellCommandRunTftp (
   EFI_HANDLE              Mtftp4ChildHandle;\r
   EFI_MTFTP4_PROTOCOL     *Mtftp4;\r
   UINTN                   FileSize;\r
+  UINTN                   DataSize;\r
   VOID                    *Data;\r
   SHELL_FILE_HANDLE       FileHandle;\r
   UINT16                  BlockSize;\r
@@ -294,6 +295,7 @@ ShellCommandRunTftp (
   AsciiRemoteFilePath = NULL;\r
   Handles             = NULL;\r
   FileSize            = 0;\r
+  DataSize            = 0;\r
   BlockSize           = MTFTP_DEFAULT_BLKSIZE;\r
 \r
   //\r
@@ -537,6 +539,7 @@ ShellCommandRunTftp (
       goto NextHandle;\r
     }\r
 \r
+    DataSize = FileSize;\r
     Status = ShellWriteFile (FileHandle, &FileSize, Data);\r
     if (!EFI_ERROR (Status)) {\r
       ShellStatus = SHELL_SUCCESS;\r
@@ -551,7 +554,7 @@ ShellCommandRunTftp (
     NextHandle:\r
 \r
     if (Data != NULL) {\r
-      gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES (FileSize));\r
+      gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES (DataSize));\r
     }\r
 \r
     CloseProtocolAndDestroyServiceChild (\r