Skip to content

Commit

Permalink
Warn and boot when efilinux.cfg has no trailing newline
Browse files Browse the repository at this point in the history
Signed-off-by: Dima Krasner <[email protected]>
  • Loading branch information
dimkr committed Dec 6, 2021
1 parent 6224016 commit 5781d55
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions entry.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,18 +334,18 @@ read_config_file(EFI_LOADED_IMAGE *image, CHAR16 **options,
*/

/* Make sure we don't overflow the UINT32 */
if (size > 0xffffffff || (size * 2) > 0xffffffff ) {
if (size >= 0xffffffff || (size * 2) >= 0xffffffff ) {
Print(L"Config file size too large. Ignoring.\n");
goto fail;
}

a_buf = malloc((UINTN)size);
a_buf = malloc((UINTN)size + 1);
if (!a_buf) {
Print(L"Failed to alloc buffer %d bytes\n", size);
goto fail;
}

u_buf = malloc((UINTN)size * 2);
u_buf = malloc((UINTN)size * 2 + 1);
if (!u_buf) {
Print(L"Failed to alloc buffer %d bytes\n", size);
free(a_buf);
Expand All @@ -368,11 +368,11 @@ read_config_file(EFI_LOADED_IMAGE *image, CHAR16 **options,
*p++ = '\0';

if (i == size && *p) {
Print(L"Error: missing newline at end of config file?\n");
goto fail;
Print(L"Warning: missing newline at end of config file?\n");
*p = '\0';
++size;
}

if ((p - a_buf) < size)
else if ((p - a_buf) < size)
Print(L"Warning: config file contains multiple lines?\n");

p = a_buf;
Expand Down

0 comments on commit 5781d55

Please sign in to comment.