}
static int pakfire_filelist_match_patterns(const char* path, const char** patterns) {
+ int flags = 0;
int r;
for (const char** pattern = patterns; *pattern; pattern++) {
if (!is_glob(*pattern))
continue;
- r = fnmatch(*pattern, path, 0);
+ // Reset flags
+ flags = 0;
+
+ /*
+ fnmatch is way too eager for patterns line /usr/lib/*.so which will also match
+ things like /usr/lib/python3.x/blah/blubb.so.
+ To prevent this for absolute file paths, we set the FNM_FILE_NAME flag so that
+ asterisk (*) won't match any slashes (/).
+ */
+ if (**pattern == '/')
+ flags |= FNM_FILE_NAME;
+
+ // Perform matching
+ r = fnmatch(*pattern, path, flags);
// Found a match
if (r == 0)