diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2019-05-31 07:35:19 +0200 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2019-05-31 23:27:12 +0200 |
commit | e6bcc354523665eace01104d1751c0a9a3039830 (patch) | |
tree | 0450ad391372a82640261b699e32a4258d4da502 /lib/efi_loader | |
parent | 3c1889e6399a0455bb5056f614be046a0b9cf053 (diff) | |
download | u-boot-e6bcc354523665eace01104d1751c0a9a3039830.tar.gz |
efi_loader: check time in SetTime()
The UEFI spec prescribes that we check that the timestamp passed to
SetTime() is checked for validity.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/efi_runtime.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_runtime.c b/lib/efi_loader/efi_runtime.c index 058b40a887..2082d1304f 100644 --- a/lib/efi_loader/efi_runtime.c +++ b/lib/efi_loader/efi_runtime.c @@ -214,6 +214,30 @@ out: #endif } +#ifdef CONFIG_DM_RTC + +/** + * efi_validate_time() - checks if timestamp is valid + * + * @time: timestamp to validate + * Returns: 0 if timestamp is valid, 1 otherwise + */ +static int efi_validate_time(struct efi_time *time) +{ + return (!time || + time->year < 1900 || time->year > 9999 || + !time->month || time->month > 12 || !time->day || + time->day > rtc_month_days(time->month - 1, time->year) || + time->hour > 23 || time->minute > 59 || time->second > 59 || + time->nanosecond > 999999999 || + time->daylight & + ~(EFI_TIME_IN_DAYLIGHT | EFI_TIME_ADJUST_DAYLIGHT) || + ((time->timezone < -1440 || time->timezone > 1440) && + time->timezone != EFI_UNSPECIFIED_TIMEZONE)); +} + +#endif + /** * efi_set_time_boottime() - set current time * @@ -235,7 +259,7 @@ static efi_status_t EFIAPI efi_set_time_boottime(struct efi_time *time) EFI_ENTRY("%p", time); - if (!time) { + if (efi_validate_time(time)) { ret = EFI_INVALID_PARAMETER; goto out; } |