summaryrefslogtreecommitdiffstats
path: root/lib/efi_loader/efi_file.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2019-07-14 20:14:46 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2019-07-16 22:17:23 +0000
commitf62be16ddb76a32e6315bb9517b49e639726e1fa (patch)
tree71fa1ead34e7e063325940c2190a956edf36127c /lib/efi_loader/efi_file.c
parent046fe7b50741363bd2df47cd01b35c0228b165bf (diff)
downloadu-boot-f62be16ddb76a32e6315bb9517b49e639726e1fa.tar.gz
u-boot-f62be16ddb76a32e6315bb9517b49e639726e1fa.tar.xz
u-boot-f62be16ddb76a32e6315bb9517b49e639726e1fa.zip
efi_loader: unaligned access in efi_file_from_path()
The device path structure is packed. So no assumption on the alignment is possible. Copy the file name in efi_file_from_path() to assure there is no unaligned access. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/efi_loader/efi_file.c')
-rw-r--r--lib/efi_loader/efi_file.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 36ca719a82..f4ca5694ee 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -755,6 +755,7 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp)
struct efi_device_path_file_path *fdp =
container_of(fp, struct efi_device_path_file_path, dp);
struct efi_file_handle *f2;
+ u16 *filename;
if (!EFI_DP_TYPE(fp, MEDIA_DEVICE, FILE_PATH)) {
printf("bad file path!\n");
@@ -762,8 +763,12 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp)
return NULL;
}
- EFI_CALL(ret = f->open(f, &f2, fdp->str,
+ filename = u16_strdup(fdp->str);
+ if (!filename)
+ return NULL;
+ EFI_CALL(ret = f->open(f, &f2, filename,
EFI_FILE_MODE_READ, 0));
+ free(filename);
if (ret != EFI_SUCCESS)
return NULL;