Skip to content

Commit

Permalink
libfwup: set_up_boot_next(): make sure we check if our file paths are…
Browse files Browse the repository at this point in the history
… NULL.

Coverity's clang scan believes we can sometimes alloca(0) if
fwup_esp_path is NULL, though I don't think this can happen because if
it is NULL get_paths() should have returned error.  Nevertheless, just
check both things.

Additionally, this adds a check to make sure utf8_to_ucs2() and
ucs2len() didn't fail.

Signed-off-by: Peter Jones <pjones@redhat.com>
  • Loading branch information
vathpela committed Jun 20, 2018
1 parent 3ce2065 commit 8819dc2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions linux/libfwup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,9 +1215,9 @@ set_up_boot_next(void)
uint32_t attributes = LOAD_OPTION_ACTIVE;

rc = get_paths(&shim_fs_path, &fwup_fs_path, &fwup_esp_path);
if (rc < 0) {
if (rc < 0 || (!shim_fs_path && (!fwup_fs_path || !fwup_esp_path))) {
efi_error("could not find paths for shim and fwup");
return -1;
goto out;
}

if (!shim_fs_path)
Expand All @@ -1242,9 +1242,17 @@ set_up_boot_next(void)

if (!use_fwup_path) {
loader_str = utf8_to_ucs2((uint8_t *)fwup_esp_path, -1);
if (loader_str == NULL) {
efi_error("utf8_to_ucs2() failed");
goto out;
}
loader_sz = ucs2len(loader_str, -1) * 2;
if (loader_sz)
loader_sz += 2;
if (loader_sz < 2) {
efi_error("ucs2len(fwup_esp_path) returned %zu",
loader_sz);
goto out;
}
loader_sz += 2;
loader_str = onstack(loader_str, loader_sz);
}

Expand Down

0 comments on commit 8819dc2

Please sign in to comment.