public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue.
@ 2018-07-12  0:44 Jiaxin Wu
  2018-07-12  0:45 ` Fu, Siyuan
  0 siblings, 1 reply; 4+ messages in thread
From: Jiaxin Wu @ 2018-07-12  0:44 UTC (permalink / raw)
  To: edk2-devel; +Cc: Jiaxin Wu, Ye Ting, Fu Siyuan, Jaben Carsey

From: Jiaxin Wu <jiaxin.wu@intel.com>

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>
---
 ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
index e2491cd54c..44be6d4e76 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
@@ -517,10 +517,12 @@ RunTftp (
         mTftpHiiHandle, RemoteFilePath, NicName, Status
       );
       goto NextHandle;
     }
 
+    DataSize = FileSize;
+
     if (!EFI_ERROR (ShellFileExists (LocalFilePath))) {
       ShellDeleteFileByName (LocalFilePath);
     }
 
     Status = ShellOpenFileByName (
@@ -537,11 +539,10 @@ RunTftp (
         mTftpHiiHandle, L"tftp", LocalFilePath
       );
       goto NextHandle;
     }
 
-    DataSize = FileSize;
     Status = ShellWriteFile (FileHandle, &FileSize, Data);
     if (!EFI_ERROR (Status)) {
       ShellStatus = SHELL_SUCCESS;
     } else {
       ShellPrintHiiEx (
-- 
2.17.1.windows.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue.
@ 2018-04-26  6:18 Jiaxin Wu
  0 siblings, 0 replies; 4+ messages in thread
From: Jiaxin Wu @ 2018-04-26  6:18 UTC (permalink / raw)
  To: edk2-devel
  Cc: Vladimir Olovyannikov, Ye Ting, Fu Siyuan, Jaben Carsey,
	Wu Jiaxin

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: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
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>
---
 ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
index 8569c966dd..0620aec1a7 100644
--- a/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
+++ b/ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c
@@ -1,10 +1,10 @@
 /** @file
   The implementation for the 'tftp' Shell command.
 
   Copyright (c) 2015, ARM Ltd. All rights reserved.<BR>
-  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved. <BR>
+  Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved. <BR>
   (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
 
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -517,10 +517,12 @@ RunTftp (
         mTftpHiiHandle, RemoteFilePath, NicName, Status
       );
       goto NextHandle;
     }
 
+    DataSize = FileSize;
+
     if (!EFI_ERROR (ShellFileExists (LocalFilePath))) {
       ShellDeleteFileByName (LocalFilePath);
     }
 
     Status = ShellOpenFileByName (
@@ -537,11 +539,10 @@ RunTftp (
         mTftpHiiHandle, L"tftp", LocalFilePath
       );
       goto NextHandle;
     }
 
-    DataSize = FileSize;
     Status = ShellWriteFile (FileHandle, &FileSize, Data);
     if (!EFI_ERROR (Status)) {
       ShellStatus = SHELL_SUCCESS;
     } else {
       ShellPrintHiiEx (
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-12 15:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-12  0:44 [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion and memory leak issue Jiaxin Wu
2018-07-12  0:45 ` Fu, Siyuan
2018-07-12 15:45   ` Carsey, Jaben
  -- strict thread matches above, loose matches on Subject: below --
2018-04-26  6:18 Jiaxin Wu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox