Skip to content

Commit

Permalink
TFTP : tftp fix for full volume case
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Meenakshi88 authored and niruiyu committed Oct 24, 2017
1 parent c13cb4a commit 34cd44d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ShellPkg/Library/UefiShellTftpCommandLib/Tftp.c
Expand Up @@ -284,6 +284,7 @@ ShellCommandRunTftp (
EFI_HANDLE Mtftp4ChildHandle;
EFI_MTFTP4_PROTOCOL *Mtftp4;
UINTN FileSize;
UINTN DataSize;
VOID *Data;
SHELL_FILE_HANDLE FileHandle;
UINT16 BlockSize;
Expand All @@ -294,6 +295,7 @@ ShellCommandRunTftp (
AsciiRemoteFilePath = NULL;
Handles = NULL;
FileSize = 0;
DataSize = 0;
BlockSize = MTFTP_DEFAULT_BLKSIZE;

//
Expand Down Expand Up @@ -537,6 +539,7 @@ ShellCommandRunTftp (
goto NextHandle;
}

DataSize = FileSize;
Status = ShellWriteFile (FileHandle, &FileSize, Data);
if (!EFI_ERROR (Status)) {
ShellStatus = SHELL_SUCCESS;
Expand All @@ -551,7 +554,7 @@ ShellCommandRunTftp (
NextHandle:

if (Data != NULL) {
gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES (FileSize));
gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)Data, EFI_SIZE_TO_PAGES (DataSize));
}

CloseProtocolAndDestroyServiceChild (
Expand Down

0 comments on commit 34cd44d

Please sign in to comment.