bootspec: validate bootpsec entry ids before we use them

This commit is contained in:
Lennart Poettering 2019-03-04 19:19:30 +01:00
parent 38bd74d67e
commit eed7210a5c

View file

@ -66,13 +66,16 @@ static int boot_entry_load(
c = endswith_no_case(path, ".conf");
if (!c)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry filename: %s", path);
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry file suffix: %s", path);
b = basename(path);
tmp.id = strndup(b, c - b);
if (!tmp.id)
return log_oom();
if (!efi_loader_entry_name_valid(tmp.id))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry filename: %s", path);
tmp.path = strdup(path);
if (!tmp.path)
return log_oom();
@ -310,6 +313,9 @@ static int boot_entry_load_unified(
if (!tmp.id)
return log_oom();
if (!efi_loader_entry_name_valid(tmp.id))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Invalid loader entry: %s", tmp.id);
tmp.path = strdup(path);
if (!tmp.path)
return log_oom();