mirror of
https://github.com/systemd/systemd.git
synced 2025-02-10 17:57:40 +03:00
boot/efi-string: check the end of haystack before testing remaining pattern
Fixes buffer-overflow reported at https://github.com/systemd/systemd/pull/23589#issuecomment-1151820341.
This commit is contained in:
parent
8bf796eeac
commit
da5fb1877d
@ -170,15 +170,11 @@ static bool efi_fnmatch_internal(const char16_t *p, const char16_t *h, int max_d
|
||||
while (*p == '*')
|
||||
p++;
|
||||
|
||||
do {
|
||||
for (; *h != '\0'; h++)
|
||||
/* Try matching haystack with remaining pattern. */
|
||||
if (efi_fnmatch_internal(p, h, max_depth - 1))
|
||||
return true;
|
||||
|
||||
/* Otherwise, we match one char here. */
|
||||
h++;
|
||||
} while (*h != '\0');
|
||||
|
||||
/* End of haystack. Pattern needs to be empty too for a match. */
|
||||
return *p == '\0';
|
||||
|
||||
|
@ -344,6 +344,7 @@ TEST(efi_fnmatch) {
|
||||
TEST_FNMATCH_ONE("*", "123", true);
|
||||
TEST_FNMATCH_ONE("**", "abcd", true);
|
||||
TEST_FNMATCH_ONE("*b*", "abcd", true);
|
||||
TEST_FNMATCH_ONE("abc*d", "abc", false);
|
||||
TEST_FNMATCH_ONE("*.conf", "arch.conf", true);
|
||||
TEST_FNMATCH_ONE("debian-*.conf", "debian-wheezy.conf", true);
|
||||
TEST_FNMATCH_ONE("debian-*.*", "debian-wheezy.efi", true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user