efi_loader: device_path: allow for arbitrary length of file path
PATCH 1/1 efi_loader: device_path: allow for arbitrary length of file path
This patch will lift the upper limit of maximum path length.
--- lib/efi_loader/efi_device_path.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
lib/efi_loader/efi_device_path.c +5 -3
@@ -1017,8 +1017,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 *filename, *s;if (path && !file)return EFI_INVALID_PARAMETER ;
@@ -1042,13 +1041,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); + filename =strdup (path); +if (!filename) +return EFI_OUT_OF_RESOURCES ;/* DOS style file path: */ s = filename;while ((s =strchr (s,'/' ))) *s++ ='\\' ; *file =efi_dp_from_file (((!is_net && device) ? desc :NULL ), part, filename); +free (filename);return EFI_SUCCESS ; }
Signature · 1 line
2.21.0
PATCH 1/1 efi_loader: device_path: allow for arbitrary length of file path
Quoted 3 lines · AKASHI Takahiro
This patch will lift the upper limit of maximum path length.
Signed-off-by AKASHI Takahiro <[email protected]>
Thanks for addressing this issue.
Please, have a look at the side effects to our implementation of the device path to text protocol. Here I assumed that a device node is at most 512 bytes long. This will no longer hold true after your patch.
I think we should fix the device path to text protocol first before merging this patch.
Quoted 9 lines
--- lib/efi_loader/efi_device_path.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)lib/efi_loader/efi_device_path.c +0
-0
lib/efi_loader/efi_device_path.c efi_status_t efi_dp_from_name(const char *dev, const char *devnr, · line 1020
Quoted 6 lines
lib/efi_loader/efi_device_path.c +1
-2@@ -1017,8 +1017,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 *filename, *s;
Below we are replacing slashes '/' by backslashes '\'. So shouldn't this variable be called filepath?
lib/efi_loader/efi_device_path.c efi_status_t efi_dp_from_name(const char *dev, const char *devnr, · line 1044
Quoted 9 lines
lib/efi_loader/efi_device_path.c +1
-1if (path && !file)return EFI_INVALID_PARAMETER ;@@ -1042,13 +1041,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); + filename =strdup (path);
Windows has a maximum file path length of 260 characters. Can we assume in EFI that a path has a maximum length of 260 characters too?
At least we must ensure that the node length does not exceed 65535 bytes, the maximum possible value in the node length field.
Best regards
Heinrich
Quoted 13 lines
lib/efi_loader/efi_device_path.c +3
-0+if (!filename) +return EFI_OUT_OF_RESOURCES ;/* DOS style file path: */ s = filename;while ((s =strchr (s,'/' ))) *s++ ='\\' ; *file =efi_dp_from_file (((!is_net && device) ? desc :NULL ), part, filename); +free (filename);return EFI_SUCCESS ; }
PATCH 1/1 efi_loader: device_path: allow for arbitrary length of file path
Quoted 10 lines · Heinrich Schuchardt
Quoted 3 lines · AKASHI Takahiro
This patch will lift the upper limit of maximum path length.
Signed-off-by AKASHI Takahiro <[email protected]>Thanks for addressing this issue.
Please, have a look at the side effects to our implementation of the device path to text protocol. Here I assumed that a device node is at most 512 bytes long. This will no longer hold true after your patch.
Whether my patch is applied or not, we may possibly hit this limitation.
Quoted 2 lines
I think we should fix the device path to text protocol first before merging this patch.
Anyhow, I will check.
Quoted 4 lines
Quoted 4 lines
--- lib/efi_loader/efi_device_path.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
Quoted 14 lines
lib/efi_loader/efi_device_path.c efi_status_t efi_dp_from_name(const char *dev, const char *devnr, · line 1020
Quoted 11 lines
lib/efi_loader/efi_device_path.c +1
-2@@ -1017,8 +1017,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 *filename, *s;Below we are replacing slashes '/' by backslashes '\'. So shouldn't this variable be called filepath?
Okay.
Quoted 7 lines
Quoted 7 lines
lib/efi_loader/efi_device_path.c +0
-0if (path && !file)return EFI_INVALID_PARAMETER ;@@ -1042,13 +1041,16 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,if (!path)return EFI_SUCCESS ;
Quoted 5 lines
lib/efi_loader/efi_device_path.c efi_status_t efi_dp_from_name(const char *dev, const char *devnr, · line 1044
Quoted 2 lines
lib/efi_loader/efi_device_path.c +1
-1-snprintf (filename,sizeof (filename),"%s" , path); + filename =strdup (path);Windows has a maximum file path length of 260 characters. Can we assume in EFI that a path has a maximum length of 260 characters too?
Why do you stick to Windows here?
In my patch of "install FILE_SYSTEM_PROTOCOL to whole disk," you wanted to allow file systems other than FAT.
Quoted 2 lines
At least we must ensure that the node length does not exceed 65535 bytes, the maximum possible value in the node length field.
Okay.
-Takahiro Akashi
Quoted 18 lines
Best regards
Heinrich
Quoted 13 lines
lib/efi_loader/efi_device_path.c +3
-0+if (!filename) +return EFI_OUT_OF_RESOURCES ;/* DOS style file path: */ s = filename;while ((s =strchr (s,'/' ))) *s++ ='\\' ; *file =efi_dp_from_file (((!is_net && device) ? desc :NULL ), part, filename); +free (filename);return EFI_SUCCESS ; }