mirror of
https://github.com/systemd/systemd.git
synced 2025-03-11 20:58:27 +03:00
Merge pull request #23688 from yuwata/boot-efi-string-efi_fnmatch-fix-over-flow
boot/efi-string: check the end of haystack before testing remaining pattern
This commit is contained in:
commit
67bca872ea
@ -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