ShellPkg/DynamicCommand/TftpDynamicCommand/Tftp.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> > -----Original Message----- > From: Wu, Jiaxin > Sent: Thursday, July 12, 2018 8:44 AM > To: edk2-devel@lists.01.org > Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu, > Siyuan <siyuan.fu@intel.com>; Carsey, Jaben <jaben.carsey@intel.com> > Subject: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential assertion > and memory leak issue. > > 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> > -----Original Message----- > From: Fu, Siyuan > Sent: Wednesday, July 11, 2018 5:46 PM > To: Wu, Jiaxin <jiaxin.wu@intel.com>; edk2-devel@lists.01.org > Cc: Ye, Ting <ting.ye@intel.com>; Carsey, Jaben <jaben.carsey@intel.com> > Subject: RE: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential > assertion and memory leak issue. > Importance: High > > > > Reviewed-by: Fu Siyuan <siyuan.fu@intel.com> > > > -----Original Message----- > > From: Wu, Jiaxin > > Sent: Thursday, July 12, 2018 8:44 AM > > To: edk2-devel@lists.01.org > > Cc: Wu, Jiaxin <jiaxin.wu@intel.com>; Ye, Ting <ting.ye@intel.com>; Fu, > > Siyuan <siyuan.fu@intel.com>; Carsey, Jaben <jaben.carsey@intel.com> > > Subject: [Patch] ShellPkg/TftpDynamicCommand: Fix the potential > assertion > > and memory leak issue. > > > > 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 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
© 2016 - 2024 Red Hat, Inc.