mirror of
https://github.com/samba-team/samba.git
synced 2025-02-02 09:47:23 +03:00
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>
This commit is contained in:
parent
f3b650fc75
commit
ea893be35a
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user