[U-Boot] [PATCH v2 3/3] efi_loader: device_path: allow for arbitrary length of file path

AKASHI Takahiro takahiro.akashi at linaro.org
Wed Oct 9 07:19:54 UTC 2019


This patch will lift the upper limit of maximum path length.

Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 lib/efi_loader/efi_device_path.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 9f772fc924fb..8be7af2b1b7d 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -1021,8 +1021,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 	struct blk_desc *desc = NULL;
 	disk_partition_t fs_partition;
 	int part = 0;
-	char filename[32] = { 0 }; /* dp->str is u16[32] long */
-	char *s;
+	char *file_path, *s;
 
 	if (path && !file)
 		return EFI_INVALID_PARAMETER;
@@ -1046,13 +1045,16 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
 	if (!path)
 		return EFI_SUCCESS;
 
-	snprintf(filename, sizeof(filename), "%s", path);
+	file_path = strdup(path);
+	if (!file_path)
+		return EFI_OUT_OF_RESOURCES;
 	/* DOS style file path: */
-	s = filename;
+	s = file_path;
 	while ((s = strchr(s, '/')))
 		*s++ = '\\';
 	*file = efi_dp_from_file(((!is_net && device) ? desc : NULL),
-				 part, filename);
+				 part, file_path);
+	free(file_path);
 
 	if (!file)
 		return EFI_INVALID_PARAMETER;
-- 
2.21.0



More information about the U-Boot mailing list