From 9d8ee7815ca7ce02555e17b60b2672674a059ce4 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Fri, 29 May 2015 14:00:39 +0000 Subject: ArmPkg/BdsLib: Fixed TFTP when there are directories in the name The TFTP Device Path might contain a list of File Path device path nodes. ConvertDevicePathToText() allows to concatenate these File Path nodes. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin Reviewed-by: Ronald Cron git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17539 6f19259b-4bc3-4df7-8a09-765794883524 --- ArmPkg/Library/BdsLib/BdsFilePath.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'ArmPkg') diff --git a/ArmPkg/Library/BdsLib/BdsFilePath.c b/ArmPkg/Library/BdsLib/BdsFilePath.c index 53af9ee76d..ff421754fe 100644 --- a/ArmPkg/Library/BdsLib/BdsFilePath.c +++ b/ArmPkg/Library/BdsLib/BdsFilePath.c @@ -1038,7 +1038,7 @@ BdsTftpLoadImage ( EFI_DHCP4_MODE_DATA Dhcp4Mode; EFI_MTFTP4_CONFIG_DATA Mtftp4CfgData; IPv4_DEVICE_PATH *IPv4DevicePathNode; - FILEPATH_DEVICE_PATH *FilePathDevicePathNode; + CHAR16 *PathName; CHAR8 *AsciiFilePath; EFI_MTFTP4_TOKEN Mtftp4Token; UINT64 FileSize; @@ -1185,17 +1185,10 @@ BdsTftpLoadImage ( goto Error; } - // - // Convert the Unicode path of the file to Ascii - // - - FilePathDevicePathNode = (FILEPATH_DEVICE_PATH*)(IPv4DevicePathNode + 1); - AsciiFilePath = AllocatePool ((StrLen (FilePathDevicePathNode->PathName) + 1) * sizeof (CHAR8)); - if (AsciiFilePath == NULL) { - Status = EFI_OUT_OF_RESOURCES; - goto Error; - } - UnicodeStrToAsciiStr (FilePathDevicePathNode->PathName, AsciiFilePath); + // The Device Path might contain multiple FilePath nodes + PathName = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL*)(IPv4DevicePathNode + 1), FALSE, FALSE); + AsciiFilePath = AllocatePool (StrLen (PathName) + 1); + UnicodeStrToAsciiStr (PathName, AsciiFilePath); // // Try to get the size of the file in bytes from the server. If it fails, @@ -1241,7 +1234,7 @@ BdsTftpLoadImage ( Mtftp4Token.CheckPacket = Mtftp4CheckPacket; Mtftp4Token.Context = (VOID*)TftpContext; - Print (L"Downloading the file <%s> from the TFTP server\n", FilePathDevicePathNode->PathName); + Print (L"Downloading the file <%a> from the TFTP server\n", AsciiFilePath); Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token); Print (L"\n"); if (EFI_ERROR (Status)) { @@ -1303,6 +1296,7 @@ Error: } if (EFI_ERROR (Status)) { + *Image = 0; Print (L"Failed to download the file - Error=%r\n", Status); } -- cgit v1.2.3