diff options
| -rw-r--r-- | include/str.h | 11 | ||||
| -rw-r--r-- | sbat.c | 10 |
2 files changed, 12 insertions, 9 deletions
diff --git a/include/str.h b/include/str.h index 0c34256d..72f87b75 100644 --- a/include/str.h +++ b/include/str.h @@ -214,4 +214,15 @@ strntoken(char *str, size_t max, const char *delims, char **token, char *state) return state_is_delim; } +#define UTF8_BOM { 0xef, 0xbb, 0xbf } +#define UTF8_BOM_SIZE 3 + +static inline UNUSED NONNULL(1) BOOLEAN +is_utf8_bom(CHAR8 *buf, size_t bufsize) +{ + unsigned char bom[] = UTF8_BOM; + + return CompareMem(buf, bom, MIN(UTF8_BOM_SIZE, bufsize)) == 0; +} + #endif /* SHIM_STR_H */ @@ -219,14 +219,6 @@ verify_sbat(size_t n, struct sbat_entry **entries) return efi_status; } -static BOOLEAN -is_utf8_bom(CHAR8 *buf, size_t bufsize) -{ - unsigned char bom[] = { 0xEF, 0xBB, 0xBF }; - - return CompareMem(buf, bom, MIN(sizeof(bom), bufsize)) == 0; -} - static struct sbat_var * new_entry(const CHAR8 *comp_name, const CHAR8 *comp_gen) { @@ -278,7 +270,7 @@ parse_sbat_var(list_t *entries) CHAR8 *start = (CHAR8 *)data; CHAR8 *end = (CHAR8 *)data + datasize; if (is_utf8_bom(start, datasize)) - start += 3; + start += UTF8_BOM_SIZE; dprint(L"SBAT variable data:\n"); |
