1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-03-08 20:58:20 +03:00

boot: Drop use of Atoi

This commit is contained in:
Jan Janssen 2022-06-01 13:42:23 +02:00
parent 72bd3458e5
commit 1621ab4600
2 changed files with 20 additions and 11 deletions

View File

@ -1159,10 +1159,12 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
else if (streq8((char *) value, "menu-hidden"))
config->timeout_sec_config = TIMEOUT_MENU_HIDDEN;
else {
_cleanup_freepool_ CHAR16 *s = NULL;
s = xstra_to_str(value);
config->timeout_sec_config = MIN(Atoi(s), TIMEOUT_TYPE_MAX);
uint64_t u;
if (!parse_number8((char *) value, &u, NULL) || u > TIMEOUT_TYPE_MAX) {
log_error_stall(L"Error parsing 'timeout' config option: %a", value);
continue;
}
config->timeout_sec_config = u;
}
config->timeout_sec = config->timeout_sec_config;
continue;
@ -1221,10 +1223,12 @@ static void config_defaults_load_from_file(Config *config, CHAR8 *content) {
else if (streq8((char *) value, "keep"))
config->console_mode = CONSOLE_MODE_KEEP;
else {
_cleanup_freepool_ CHAR16 *s = NULL;
s = xstra_to_str(value);
config->console_mode = MIN(Atoi(s), (UINTN)CONSOLE_MODE_RANGE_MAX);
uint64_t u;
if (!parse_number8((char *) value, &u, NULL) || u > CONSOLE_MODE_RANGE_MAX) {
log_error_stall(L"Error parsing 'console-mode' config option: %a", value);
continue;
}
config->console_mode = u;
}
continue;
}

View File

@ -127,16 +127,21 @@ EFI_STATUS efivar_get(const EFI_GUID *vendor, const CHAR16 *name, CHAR16 **value
EFI_STATUS efivar_get_uint_string(const EFI_GUID *vendor, const CHAR16 *name, UINTN *i) {
_cleanup_freepool_ CHAR16 *val = NULL;
EFI_STATUS err;
uint64_t u;
assert(vendor);
assert(name);
assert(i);
err = efivar_get(vendor, name, &val);
if (!EFI_ERROR(err))
*i = Atoi(val);
if (err != EFI_SUCCESS)
return err;
return err;
if (!parse_number16(val, &u, NULL) || u > UINTN_MAX)
return EFI_INVALID_PARAMETER;
*i = u;
return EFI_SUCCESS;
}
EFI_STATUS efivar_get_uint32_le(const EFI_GUID *vendor, const CHAR16 *name, UINT32 *ret) {