summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-10-25 12:46:00 +0200
committerRalph Boehme <slow@samba.org>2017-01-22 18:30:12 +0100
commita551d3826d885f22eed33aac56df697f32f854d4 (patch)
tree878b9852d6ce1784ec316b6d415b1e1a555744ce /lib
parentb4ed72a2d3b08128ee03202512914cfbe21b6c91 (diff)
downloadsamba-a551d3826d885f22eed33aac56df697f32f854d4.tar.gz
lib/util: Avoid a talloc in ms_fnmatch_protocol
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/util/ms_fnmatch.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c
index 7f1cce06bb1..c0f61ab04e7 100644
--- a/lib/util/ms_fnmatch.c
+++ b/lib/util/ms_fnmatch.c
@@ -165,7 +165,6 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
bool is_case_sensitive)
{
int ret, count, i;
- struct max_n *max_n = NULL;
if (strcmp(string, "..") == 0) {
string = ".";
@@ -210,15 +209,14 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
if (pattern[i] == '*' || pattern[i] == '<') count++;
}
- max_n = talloc_zero_array(NULL, struct max_n, count);
- if (max_n == NULL) {
- return -1;
- }
+ {
+ struct max_n max_n[count];
- ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
- is_case_sensitive);
+ memset(max_n, 0, sizeof(struct max_n) * count);
- talloc_free(max_n);
+ ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
+ is_case_sensitive);
+ }
return ret;
}