core: accept %NULL argument to nm_wildcard_match_check()

%NULL means that the string is unknown. The pattern should still match
if there are no positive matches that want to match against the string.

For example, the nm_device_get_driver() might return NULL. If we have
a match.driver setting, we still need to handle that somehow that it
makes sense.
This commit is contained in:
Thomas Haller 2020-05-06 16:10:30 +02:00
parent ace437338d
commit 623cf7c9a3
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1703,11 +1703,13 @@ nm_wildcard_match_check (const char *str,
const char *const *patterns,
guint num_patterns)
{
guint i, neg = 0;
gsize i, neg = 0;
for (i = 0; i < num_patterns; i++) {
if (patterns[i][0] == '!') {
neg++;
if (!str)
continue;
if (!fnmatch (patterns[i] + 1, str, 0))
return FALSE;
}
@ -1716,10 +1718,12 @@ nm_wildcard_match_check (const char *str,
if (neg == num_patterns)
return TRUE;
for (i = 0; i < num_patterns; i++) {
if ( patterns[i][0] != '!'
&& !fnmatch (patterns[i], str, 0))
return TRUE;
if (str) {
for (i = 0; i < num_patterns; i++) {
if ( patterns[i][0] != '!'
&& !fnmatch (patterns[i], str, 0))
return TRUE;
}
}
return FALSE;