diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-05-25 12:07:30 +0200 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2021-05-25 13:06:57 +0200 |
commit | 9a6b33bef246460215ce1d45e77f98c5aa57f6d0 (patch) | |
tree | 37ac8712af0929067c454ff4d65e9592d481cbae | |
parent | f6081a8a1e45e4864e36d83ccc236eef62478b1f (diff) | |
download | u-boot-9a6b33bef246460215ce1d45e77f98c5aa57f6d0.zip u-boot-9a6b33bef246460215ce1d45e77f98c5aa57f6d0.tar.gz u-boot-9a6b33bef246460215ce1d45e77f98c5aa57f6d0.tar.bz2 |
efi_loader: path length in efi_dp_from_name()
Before this patch efi_dp_from_name() only accommodated a maximum file path
length of 31 characters. This leads to boot failures due to file name
truncation.
Allow arbitrary path lengths.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r-- | lib/efi_loader/efi_device_path.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index 4b20859..76c2f82 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -1171,7 +1171,7 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr, struct blk_desc *desc = NULL; struct disk_partition fs_partition; int part = 0; - char filename[32] = { 0 }; /* dp->str is u16[32] long */ + char *filename; char *s; if (path && !file) @@ -1198,12 +1198,17 @@ 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 = calloc(1, strlen(path) + 1); + if (!filename) + return EFI_OUT_OF_RESOURCES; + + sprintf(filename, "%s", path); /* DOS style file path: */ s = filename; while ((s = strchr(s, '/'))) *s++ = '\\'; *file = efi_dp_from_file(desc, part, filename); + free(filename); if (!*file) return EFI_INVALID_PARAMETER; |