mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 15:28:50 +00:00
efi_loader: check parameters of efi_file_open()
Check the parameters of efi_file_open(). Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:
parent
a90bf07afc
commit
143acd1ef1
1 changed files with 26 additions and 4 deletions
|
@ -202,15 +202,37 @@ static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,
|
||||||
s16 *file_name, u64 open_mode, u64 attributes)
|
s16 *file_name, u64 open_mode, u64 attributes)
|
||||||
{
|
{
|
||||||
struct file_handle *fh = to_fh(file);
|
struct file_handle *fh = to_fh(file);
|
||||||
|
efi_status_t ret;
|
||||||
|
|
||||||
EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name,
|
EFI_ENTRY("%p, %p, \"%ls\", %llx, %llu", file, new_handle, file_name,
|
||||||
open_mode, attributes);
|
open_mode, attributes);
|
||||||
|
|
||||||
*new_handle = file_open(fh->fs, fh, file_name, open_mode, attributes);
|
/* Check parameters */
|
||||||
if (!*new_handle)
|
if (!file || !file || !file_name) {
|
||||||
return EFI_EXIT(EFI_NOT_FOUND);
|
ret = EFI_INVALID_PARAMETER;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if (open_mode != EFI_FILE_MODE_READ &&
|
||||||
|
open_mode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE) &&
|
||||||
|
open_mode != (EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE |
|
||||||
|
EFI_FILE_MODE_CREATE)) {
|
||||||
|
ret = EFI_INVALID_PARAMETER;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
if ((!(open_mode & EFI_FILE_MODE_CREATE) && attributes) ||
|
||||||
|
(attributes & (EFI_FILE_READ_ONLY | ~EFI_FILE_VALID_ATTR))) {
|
||||||
|
ret = EFI_INVALID_PARAMETER;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
return EFI_EXIT(EFI_SUCCESS);
|
/* Open file */
|
||||||
|
*new_handle = file_open(fh->fs, fh, file_name, open_mode, attributes);
|
||||||
|
if (*new_handle)
|
||||||
|
ret = EFI_SUCCESS;
|
||||||
|
else
|
||||||
|
ret = EFI_NOT_FOUND;
|
||||||
|
out:
|
||||||
|
return EFI_EXIT(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static efi_status_t file_close(struct file_handle *fh)
|
static efi_status_t file_close(struct file_handle *fh)
|
||||||
|
|
Loading…
Add table
Reference in a new issue