From: Volker Lendecke Date: Fri, 16 Jun 2023 11:53:25 +0000 (+0200) Subject: smbd: smbd_dirptr_lanman2_match_fn(): Remove "exact_match" handling X-Git-Tag: talloc-2.4.1~336 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96a64fb3333eb62f87e4b55e2c51fd501a13fd7f;p=thirdparty%2Fsamba.git smbd: smbd_dirptr_lanman2_match_fn(): Remove "exact_match" handling 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 Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Jun 16 17:07:46 UTC 2023 on atb-devel-224 --- diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index aac58c7b598..afa89148a4c 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -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,'/');