summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2016-10-25 11:53:53 +0200
committerRalph Boehme <slow@samba.org>2017-01-22 18:30:12 +0100
commitf969be54417a0d4d2bab0f854ce1c9f9d4639711 (patch)
treee542d9409e8d21f43c71f47413da9e70b42b90ee /lib
parent07d9a909ba6853fb0b96f6d86e4cf0d5d1b35b28 (diff)
downloadsamba-f969be54417a0d4d2bab0f854ce1c9f9d4639711.tar.gz
lib: Add "is_case_sensitive" to 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.c29
-rw-r--r--lib/util/samba_util.h3
2 files changed, 21 insertions, 11 deletions
diff --git a/lib/util/ms_fnmatch.c b/lib/util/ms_fnmatch.c
index ede9eff78f8..7f1cce06bb1 100644
--- a/lib/util/ms_fnmatch.c
+++ b/lib/util/ms_fnmatch.c
@@ -59,7 +59,8 @@ struct max_n {
not contain a '.', otherwise it points at the last dot in 'n'.
*/
static int ms_fnmatch_core(const char *p, const char *n,
- struct max_n *max_n, const char *ldot)
+ struct max_n *max_n, const char *ldot,
+ bool is_case_sensitive)
{
codepoint_t c, c2;
int i;
@@ -76,7 +77,7 @@ static int ms_fnmatch_core(const char *p, const char *n,
}
for (i=0; n[i]; i += size_n) {
next_codepoint(n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) {
+ if (ms_fnmatch_core(p, n+i, max_n+1, ldot, is_case_sensitive) == 0) {
return 0;
}
}
@@ -95,9 +96,9 @@ static int ms_fnmatch_core(const char *p, const char *n,
}
for (i=0; n[i]; i += size_n) {
next_codepoint(n+i, &size_n);
- if (ms_fnmatch_core(p, n+i, max_n+1, ldot) == 0) return 0;
+ if (ms_fnmatch_core(p, n+i, max_n+1, ldot, is_case_sensitive) == 0) return 0;
if (n+i == ldot) {
- if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot) == 0) return 0;
+ if (ms_fnmatch_core(p, n+i+size_n, max_n+1, ldot, is_case_sensitive) == 0) return 0;
if (!max_n->postdot || max_n->postdot > n) max_n->postdot = n;
return -1;
}
@@ -140,8 +141,13 @@ static int ms_fnmatch_core(const char *p, const char *n,
default:
c2 = next_codepoint(n, &size_n);
- if (c != c2 && codepoint_cmpi(c, c2) != 0) {
- return -1;
+ if (c != c2) {
+ if (is_case_sensitive) {
+ return -1;
+ }
+ if (codepoint_cmpi(c, c2) != 0) {
+ return -1;
+ }
}
n += size_n;
break;
@@ -155,7 +161,8 @@ static int ms_fnmatch_core(const char *p, const char *n,
return -1;
}
-int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
+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;
@@ -193,7 +200,8 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
p[i] = '<';
}
}
- ret = ms_fnmatch_protocol(p, string, PROTOCOL_NT1);
+ ret = ms_fnmatch_protocol(p, string, PROTOCOL_NT1,
+ is_case_sensitive);
talloc_free(p);
return ret;
}
@@ -207,7 +215,8 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
return -1;
}
- ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'));
+ ret = ms_fnmatch_core(pattern, string, max_n, strrchr(string, '.'),
+ is_case_sensitive);
talloc_free(max_n);
@@ -218,5 +227,5 @@ int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol)
/** a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string)
{
- return ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1);
+ return ms_fnmatch_protocol(pattern, string, PROTOCOL_NT1, false);
}
diff --git a/lib/util/samba_util.h b/lib/util/samba_util.h
index 5dcaf947b38..aad44dc4c26 100644
--- a/lib/util/samba_util.h
+++ b/lib/util/samba_util.h
@@ -526,7 +526,8 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize);
* @brief MS-style Filename matching
*/
-int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol);
+int ms_fnmatch_protocol(const char *pattern, const char *string, int protocol,
+ bool is_case_sensitive);
/** a generic fnmatch function - uses for non-CIFS pattern matching */
int gen_fnmatch(const char *pattern, const char *string);