summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/bcd.c
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2021-12-27 22:49:02 +0100
committerJan Janssen <medhefgo@web.de>2021-12-27 22:49:02 +0100
commit2198a773916f0e4ecca01725118f1f5a6bbe27b1 (patch)
tree4f7544bbd975bb9053e7ab2c4f45b55b9efd0653 /src/boot/efi/bcd.c
parentboot: Fix off-by-one offset sanity checks (diff)
downloadsystemd-2198a773916f0e4ecca01725118f1f5a6bbe27b1.tar.xz
systemd-2198a773916f0e4ecca01725118f1f5a6bbe27b1.zip
boot: Fix name length comparison
Diffstat (limited to 'src/boot/efi/bcd.c')
-rw-r--r--src/boot/efi/bcd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/boot/efi/bcd.c b/src/boot/efi/bcd.c
index 07948392ff..44c544f8f7 100644
--- a/src/boot/efi/bcd.c
+++ b/src/boot/efi/bcd.c
@@ -19,6 +19,7 @@
# define UINT32 uint32_t
# define UINT64 uint64_t
# define UINTN size_t
+# define strlena(s) strlen(s)
# define strncaseeqa(a, b, n) strncaseeq((a), (b), (n))
# define TEST_STATIC static
#endif
@@ -157,7 +158,7 @@ static const Key *get_key(const UINT8 *bcd, UINT32 bcd_len, UINT32 offset, const
return NULL;
if (*name) {
- if (strncaseeqa(name, key->key_name, key->key_name_len) && !name[key->key_name_len])
+ if (strncaseeqa(name, key->key_name, key->key_name_len) && strlena(name) == key->key_name_len)
name += key->key_name_len;
else
return NULL;
@@ -201,7 +202,7 @@ static const KeyValue *get_key_value(const UINT8 *bcd, UINT32 bcd_len, const Key
if ((UINT64) kv->data_offset + kv->data_size >= bcd_len)
continue;
- if (strncaseeqa(name, kv->name, kv->name_len) && !name[kv->name_len])
+ if (strncaseeqa(name, kv->name, kv->name_len) && strlena(name) == kv->name_len)
return kv;
}