container_of(fp, struct efi_device_path_file_path, dp);
struct efi_file_handle *f2;
u16 *filename;
+ size_t filename_sz;
if (!EFI_DP_TYPE(fp, MEDIA_DEVICE, FILE_PATH)) {
printf("bad file path!\n");
* protocol member functions to be aligned. So memcpy it
* unconditionally
*/
- filename = u16_strdup(fdp->str);
+ if (fdp->dp.length <= offsetof(struct efi_device_path_file_path, str))
+ return NULL;
+ filename_sz = fdp->dp.length -
+ offsetof(struct efi_device_path_file_path, str);
+ filename = malloc(filename_sz);
if (!filename)
return NULL;
+ memcpy(filename, fdp->str, filename_sz);
EFI_CALL(ret = f->open(f, &f2, filename,
EFI_FILE_MODE_READ, 0));
free(filename);