]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/BdsLib: Fixed TFTP when there are directories in the name
authorOlivier Martin <Olivier.Martin@arm.com>
Fri, 29 May 2015 14:00:39 +0000 (14:00 +0000)
committeroliviermartin <oliviermartin@Edk2>
Fri, 29 May 2015 14:00:39 +0000 (14:00 +0000)
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 <Olivier.Martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17539 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/BdsLib/BdsFilePath.c

index 53af9ee76d36830c6a68619dca2c23703b667ebd..ff421754fe214d9a5e161b73af418be86d401768 100644 (file)
@@ -1038,7 +1038,7 @@ BdsTftpLoadImage (
   EFI_DHCP4_MODE_DATA      Dhcp4Mode;\r
   EFI_MTFTP4_CONFIG_DATA   Mtftp4CfgData;\r
   IPv4_DEVICE_PATH         *IPv4DevicePathNode;\r
-  FILEPATH_DEVICE_PATH     *FilePathDevicePathNode;\r
+  CHAR16                   *PathName;\r
   CHAR8                    *AsciiFilePath;\r
   EFI_MTFTP4_TOKEN         Mtftp4Token;\r
   UINT64                   FileSize;\r
@@ -1185,17 +1185,10 @@ BdsTftpLoadImage (
     goto Error;\r
   }\r
 \r
-  //\r
-  // Convert the Unicode path of the file to Ascii\r
-  //\r
-\r
-  FilePathDevicePathNode = (FILEPATH_DEVICE_PATH*)(IPv4DevicePathNode + 1);\r
-  AsciiFilePath = AllocatePool ((StrLen (FilePathDevicePathNode->PathName) + 1) * sizeof (CHAR8));\r
-  if (AsciiFilePath == NULL) {\r
-    Status = EFI_OUT_OF_RESOURCES;\r
-    goto Error;\r
-  }\r
-  UnicodeStrToAsciiStr (FilePathDevicePathNode->PathName, AsciiFilePath);\r
+  // The Device Path might contain multiple FilePath nodes\r
+  PathName      = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL*)(IPv4DevicePathNode + 1), FALSE, FALSE);\r
+  AsciiFilePath = AllocatePool (StrLen (PathName) + 1);\r
+  UnicodeStrToAsciiStr (PathName, AsciiFilePath);\r
 \r
   //\r
   // Try to get the size of the file in bytes from the server. If it fails,\r
@@ -1241,7 +1234,7 @@ BdsTftpLoadImage (
     Mtftp4Token.CheckPacket = Mtftp4CheckPacket;\r
     Mtftp4Token.Context     = (VOID*)TftpContext;\r
 \r
-    Print (L"Downloading the file <%s> from the TFTP server\n", FilePathDevicePathNode->PathName);\r
+    Print (L"Downloading the file <%a> from the TFTP server\n", AsciiFilePath);\r
     Status = Mtftp4->ReadFile (Mtftp4, &Mtftp4Token);\r
     Print (L"\n");\r
     if (EFI_ERROR (Status)) {\r
@@ -1303,6 +1296,7 @@ Error:
   }\r
 \r
   if (EFI_ERROR (Status)) {\r
+    *Image = 0;\r
     Print (L"Failed to download the file - Error=%r\n", Status);\r
   }\r
 \r