1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-01 04:58:35 +03:00

lib/util: Avoid a talloc in ms_fnmatch_protocol

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Volker Lendecke 2016-10-25 12:46:00 +02:00 committed by Ralph Boehme
parent b4ed72a2d3
commit a551d3826d

View File

@ -165,7 +165,6 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
bool is_case_sensitive) bool is_case_sensitive)
{ {
int ret, count, i; int ret, count, i;
struct max_n *max_n = NULL;
if (strcmp(string, "..") == 0) { if (strcmp(string, "..") == 0) {
string = "."; string = ".";
@ -210,16 +209,15 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
if (pattern[i] == '*' || pattern[i] == '<') count++; if (pattern[i] == '*' || pattern[i] == '<') count++;
} }
max_n = talloc_zero_array(NULL, struct max_n, count); {
if (max_n == NULL) { struct max_n max_n[count];
return -1;
memset(max_n, 0, sizeof(struct max_n) * count);
ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
is_case_sensitive);
} }
ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
is_case_sensitive);
talloc_free(max_n);
return ret; return ret;
} }