smbd: smbd_dirptr_lanman2_match_fn(): Remove "exact_match" handling
authorVolker Lendecke <vl@samba.org>
Fri, 16 Jun 2023 11:53:25 +0000 (13:53 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 16 Jun 2023 17:07:46 +0000 (17:07 +0000)
No caller uses this anymore. The only downside here now is that we
always go directly to mask_match instead of a trying strcasecmp_m
first. I very much doubt this makes a measurable difference because
this would have been called for non-wildcard
readdirs (a.k.a. qpathinfo), and there we do this only once per
complete directory read. Also I don't believe mask_match() is
measurably more expensive than strcasecmp_m() for the usually short
filenames we're looking at here.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Jun 16 17:07:46 UTC 2023 on atb-devel-224

source3/smbd/smb2_trans2.c

index aac58c7b598a89e3cb1540ff504181498d4bfa22..afa89148a4ca13ecfa3393a2c5ee9cf61d68ec07 100644 (file)
@@ -832,33 +832,6 @@ static struct ea_list *ea_list_union(struct ea_list *name_list, struct ea_list *
        return name_list;
 }
 
-/*********************************************************
- Routine to check if a given string matches exactly.
- as a special case a mask of "." does NOT match. That
- is required for correct wildcard semantics
- Case can be significant or not.
-**********************************************************/
-
-static bool exact_match(bool has_wild,
-                       bool case_sensitive,
-                       const char *str,
-                       const char *mask)
-{
-       if (ISDOT(mask)) {
-               return false;
-       }
-
-       if (has_wild) {
-               return false;
-       }
-
-       if (case_sensitive) {
-               return strcmp(str,mask)==0;
-       } else {
-               return strcasecmp_m(str,mask) == 0;
-       }
-}
-
 /****************************************************************************
  Return the filetype for UNIX extensions.
 ****************************************************************************/
@@ -980,8 +953,6 @@ struct smbd_dirptr_lanman2_state {
        connection_struct *conn;
        uint32_t info_level;
        bool check_mangled_names;
-       bool has_wild;
-       bool got_exact_match;
        bool case_sensitive;
 };
 
@@ -1035,14 +1006,8 @@ static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx,
                fname = dname;
        }
 
-       got_match = exact_match(state->has_wild,
-                               state->case_sensitive,
-                               fname, mask);
-       state->got_exact_match = got_match;
-       if (!got_match) {
-               got_match = mask_match(fname, mask,
-                                      state->case_sensitive);
-       }
+       got_match = mask_match(fname, mask,
+                              state->case_sensitive);
 
        if(!got_match && state->check_mangled_names &&
           !mangle_is_8_3(fname, false, state->conn->params)) {
@@ -1059,14 +1024,8 @@ static bool smbd_dirptr_lanman2_match_fn(TALLOC_CTX *ctx,
                        return false;
                }
 
-               got_match = exact_match(state->has_wild,
-                                       state->case_sensitive,
-                                       mangled_name, mask);
-               state->got_exact_match = got_match;
-               if (!got_match) {
-                       got_match = mask_match(mangled_name, mask,
-                                              state->case_sensitive);
-               }
+               got_match = mask_match(mangled_name, mask,
+                                      state->case_sensitive);
        }
 
        if (!got_match) {
@@ -1936,8 +1895,6 @@ NTSTATUS smbd_dirptr_lanman2_entry(TALLOC_CTX *ctx,
        if (mangled_names != MANGLED_NAMES_NO) {
                state.check_mangled_names = true;
        }
-       state.has_wild = dptr_has_wild(dirptr);
-       state.got_exact_match = false;
        state.case_sensitive = dptr_case_sensitive(dirptr);
 
        p = strrchr_m(path_mask,'/');