lib: Fix "is_case_sensitive" in "ms_fnmatch_protocol"' callers
authorVolker Lendecke <vl@samba.org>
Sun, 12 Feb 2017 19:12:10 +0000 (20:12 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 15 Feb 2017 10:40:32 +0000 (11:40 +0100)
In the optimization in f969be54417 I got the boolean flag "is_case_sensitive"
wrong. The behaviour was case *insensitive*, so all the flags should have been
"false", keeping the old behaviour.  While there, simplify "mask_match" in
source4 client.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Feb 15 11:40:32 CET 2017 on sn-devel-144

source4/client/client.c
source4/ntvfs/cifs_posix_cli/svfs_util.c
source4/ntvfs/posix/pvfs_dirlist.c
source4/ntvfs/simple/svfs_util.c
source4/torture/masktest.c

index 10d027b5e0bfe8c40f3ec28fedf80de1544266b8..1182e5be013e0d3586821ff18fe5ed263ac77362 100644 (file)
@@ -302,27 +302,17 @@ static int cmd_cd(struct smbclient_context *ctx, const char **args)
 static bool mask_match(struct smbcli_state *c, const char *string, 
                const char *pattern, bool is_case_sensitive)
 {
-       char *p2, *s2;
-       bool ret;
+       int ret;
 
        if (ISDOTDOT(string))
                string = ".";
        if (ISDOT(pattern))
                return false;
-       
-       if (is_case_sensitive)
-               return ms_fnmatch_protocol(
-                       pattern, string, c->transport->negotiate.protocol,
-                       true) == 0;
-
-       p2 = strlower_talloc(NULL, pattern);
-       s2 = strlower_talloc(NULL, string);
-       ret = ms_fnmatch_protocol(p2, s2, c->transport->negotiate.protocol,
-                                 true) == 0;
-       talloc_free(p2);
-       talloc_free(s2);
-
-       return ret;
+
+       ret = ms_fnmatch_protocol(pattern, string,
+                                 c->transport->negotiate.protocol,
+                                 is_case_sensitive);
+       return (ret == 0);
 }
 
 
index ec2e933080602ad900a4a63523fe87267ded7fc2..0efab832199ccbbfa9c053829cbb3af904fe7d9c 100644 (file)
@@ -106,7 +106,7 @@ struct cifspsx_dir *cifspsx_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request
 
                /* check it matches the wildcard pattern */
                if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1,
-                                       true) != 0) {
+                                       false) != 0) {
                        continue;
                }
                
index d86fce4e85252b02b8323b7463a65e40f5b810cb..a503404015414b218f6eb2dd13f355f857f2770a 100644 (file)
@@ -200,7 +200,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
                (*ofs) = DIR_OFFSET_DOTDOT;
                dir->offset = *ofs;
                if (ms_fnmatch_protocol(dir->pattern, ".", protocol,
-                                       true) == 0) {
+                                       false) == 0) {
                        dcache_add(dir, ".");
                        return ".";
                }
@@ -210,7 +210,7 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
                (*ofs) = DIR_OFFSET_BASE;
                dir->offset = *ofs;
                if (ms_fnmatch_protocol(dir->pattern, "..", protocol,
-                                       true) == 0) {
+                                       false) == 0) {
                        dcache_add(dir, "..");
                        return "..";
                }
@@ -231,11 +231,11 @@ const char *pvfs_list_next(struct pvfs_dir *dir, off_t *ofs)
                }
 
                if (ms_fnmatch_protocol(dir->pattern, dname, protocol,
-                                       true) != 0) {
+                                       false) != 0) {
                        char *short_name = pvfs_short_name_component(dir->pvfs, dname);
                        if (short_name == NULL ||
                            ms_fnmatch_protocol(dir->pattern, short_name,
-                                               protocol, true) != 0) {
+                                               protocol, false) != 0) {
                                talloc_free(short_name);
                                continue;
                        }
index 21f20c58ac8a1d930e267e5aec424c30303a7257..d1901ae01994c3ac180d67465c12b9f486530fbe 100644 (file)
@@ -102,7 +102,7 @@ struct svfs_dir *svfs_list_unix(TALLOC_CTX *mem_ctx, struct ntvfs_request *req,
 
                /* check it matches the wildcard pattern */
                if (ms_fnmatch_protocol(low_mask, low_name, PROTOCOL_NT1,
-                                       true) != 0) {
+                                       false) != 0) {
                        continue;
                }
                
index e6e7f4e4245d50759567d1d94ced0e008c460c4c..2097de4e5febe53b5e0f5e7ccf2ae993520abe06 100644 (file)
@@ -50,7 +50,7 @@ static bool reg_match_one(struct smbcli_state *cli, const char *pattern, const c
        if (ISDOTDOT(file)) file = ".";
 
        return ms_fnmatch_protocol(
-               pattern, file, cli->transport->negotiate.protocol, true)==0;
+               pattern, file, cli->transport->negotiate.protocol, false)==0;
 }
 
 static char *reg_test(struct smbcli_state *cli, TALLOC_CTX *mem_ctx, const char *pattern, const char *long_name, const char *short_name)