mirror of
https://github.com/systemd/systemd.git
synced 2026-08-09 17:38:42 +00:00
sysupdate: handle slashes after pattern fields
Patterns such as foo_@v/bar.efi are documented to match files in versioned subdirectories, but pattern_match() assumed that a field is always followed by a literal when another element exists. Handle a following slash as a delimiter too, and request another recursion step when the current path ends before that slash. Fixes #42895. Signed-off-by: dongshengyuan <dongshengyuan@uniontech.com>
This commit is contained in:
@@ -248,12 +248,14 @@ int pattern_match(const char *pattern, const char *s, InstanceMetadata *ret) {
|
||||
}
|
||||
|
||||
if (e->elements_next) {
|
||||
/* The next element must be literal, as we use it to determine where to split */
|
||||
assert(e->elements_next->type == PATTERN_LITERAL);
|
||||
|
||||
n = strstr(p, e->elements_next->literal);
|
||||
if (!n)
|
||||
goto nope;
|
||||
if (e->elements_next->type == PATTERN_LITERAL) {
|
||||
n = strstr(p, e->elements_next->literal);
|
||||
if (!n)
|
||||
goto nope;
|
||||
} else if (e->elements_next->type == PATTERN_SLASH)
|
||||
n = strchrnul(p, '/');
|
||||
else
|
||||
assert_not_reached();
|
||||
|
||||
} else
|
||||
/* End of the string */
|
||||
|
||||
Reference in New Issue
Block a user