Skip to content

Commit 14d6339

Browse files
frozencemeteryvathpela
authored andcommitted
Discard load-options that start with a NUL
In 6c8d08c ("shim: Ignore UEFI LoadOptions that are just NUL characters."), a check was added to discard load options that are entirely NUL. We now see some firmwares that start LoadOptions with a NUL, and then follow it with garbage (path to directory containing loaders). Widen the check to just discard anything that starts with a NUL. Resolves: #490 Related: #95 See-also: https://bugzilla.redhat.com/show_bug.cgi?id=2113005 Signed-off-by: Robbie Harwood <[email protected]>
1 parent 4fd484e commit 14d6339

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

include/ucs2.h

-18
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,4 @@ StrCSpn(const CHAR16 *s, const CHAR16 *reject)
6363
return ret;
6464
}
6565

66-
/*
67-
* Test if an entire buffer is nothing but NUL characters. This
68-
* implementation "gracefully" ignores the difference between the
69-
* UTF-8/ASCII 1-byte NUL and the UCS-2 2-byte NUL.
70-
*/
71-
static inline bool
72-
__attribute__((__unused__))
73-
is_all_nuls(UINT8 *data, UINTN data_size)
74-
{
75-
UINTN i;
76-
77-
for (i = 0; i < data_size; i++) {
78-
if (data[i] != 0)
79-
return false;
80-
}
81-
return true;
82-
}
83-
8466
#endif /* SHIM_UCS2_H */

load-options.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -404,8 +404,13 @@ parse_load_options(EFI_LOADED_IMAGE *li)
404404

405405
/*
406406
* Apparently sometimes we get L"\0\0"? Which isn't useful at all.
407+
*
408+
* Possibly related, but some boards have additional data before the
409+
* size which is garbage (it's a weird path to the directory
410+
* containing the loaders). Known boards that do this: Kontron VX3040
411+
* (AMI), ASUS B85M-E, and at least one "older Dell laptop".
407412
*/
408-
if (is_all_nuls(li->LoadOptions, li->LoadOptionsSize))
413+
if (((CHAR16 *)li->LoadOptions)[0] == 0)
409414
return EFI_SUCCESS;
410415

411416
/*

0 commit comments

Comments
 (0)