From: Jeremy Allison Date: Wed, 22 Aug 2018 16:15:12 +0000 (-0700) Subject: s3: smbd: Restructure check_parent_exists() to ensure all non-optimization returns... X-Git-Tag: tdb-1.3.17~1648 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=de7541059360b597c3d2ea383b0eb2fc2f7018d5;p=thirdparty%2Fsamba.git s3: smbd: Restructure check_parent_exists() to ensure all non-optimization returns go to one place. Signed-off-by: Jeremy Allison Reviewed-by: Michael Adam --- diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 2071ddc58d6..479d532327a 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -168,7 +168,6 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx, const char *last_component = NULL; NTSTATUS status; int ret; - bool parent_fname_has_wild = false; if (!parent_dirname(ctx, smb_fname->base_name, &parent_fname.base_name, @@ -177,18 +176,18 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx, } if (!posix_pathnames) { - parent_fname_has_wild = ms_has_wild(parent_fname.base_name); + if (ms_has_wild(parent_fname.base_name)) { + goto no_optimization_out; + } } /* * If there was no parent component in - * smb_fname->base_name of the parent name - * contained a wildcard then don't do this + * smb_fname->base_name then don't do this * optimization. */ - if ((smb_fname->base_name == last_component) || - parent_fname_has_wild) { - return NT_STATUS_OK; + if (smb_fname->base_name == last_component) { + goto no_optimization_out; } if (posix_pathnames) { @@ -201,7 +200,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx, with the normal tree walk. */ if (ret == -1) { - return NT_STATUS_OK; + goto no_optimization_out; } status = check_for_dot_component(&parent_fname); @@ -234,6 +233,10 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx, *pp_start)); return NT_STATUS_OK; + + no_optimization_out: + + return NT_STATUS_OK; } /*