diff options
author | Andreas Schneider <asn@samba.org> | 2017-10-26 09:47:57 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-03-02 14:07:14 +0100 |
commit | ea893be35a909c35d5a977a5abd76cb48e24eed6 (patch) | |
tree | a964bb318b354798f1e13141b47dd5fd9ae4cb59 /lib/util/ms_fnmatch.c | |
parent | f3b650fc75b8edb27a852b88f469e8cd4a317f99 (diff) | |
download | samba-ea893be35a909c35d5a977a5abd76cb48e24eed6.tar.gz |
util: Fix the logic in ms_fnmatch_protocol()
Make sure we always pass a valid max_n pointer to ms_fnmatch_core().
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
Diffstat (limited to 'lib/util/ms_fnmatch.c')
-rw-r--r-- | lib/util/ms_fnmatch.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c index c0f61ab04e7..636ac399f66 100644 --- a/lib/util/ms_fnmatch.c +++ b/lib/util/ms_fnmatch.c @@ -164,7 +164,8 @@ static int ms_fnmatch_core(const char *p, const char *n, int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol, bool is_case_sensitive) { - int ret, count, i; + int ret = -1; + size_t count, i; if (strcmp(string, "..") == 0) { string = "."; @@ -209,13 +210,17 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol, if (pattern[i] == '*' || pattern[i] == '<') count++; } - { + /* If the pattern includes '*' or '<' */ + if (count >= 1) { struct max_n max_n[count]; memset(max_n, 0, sizeof(struct max_n) * count); ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'), is_case_sensitive); + } else { + ret = ms_fnmatch_core(pattern, string, NULL, strrchr(string, '.'), + is_case_sensitive); } return ret; |