]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Restructure check_parent_exists() to ensure all non-optimization returns...
authorJeremy Allison <jra@samba.org>
Wed, 22 Aug 2018 16:15:12 +0000 (09:15 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 11 Sep 2018 20:45:10 +0000 (22:45 +0200)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
source3/smbd/filename.c

index 2071ddc58d6c5a9ef517d190ccc11506c50316c4..479d532327a039981dc3740abc6a1936ff9b372b 100644 (file)
@@ -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;
 }
 
 /*