s3:smbd: check for allow_wcard_last_component early in unix_convert()
[metze/samba/wip.git] / source3 / smbd / filename.c
index d8137989f66dc430a0e785d9dbda2db2640dd89b..81532a06dac8c819e66f168886ac71dc04763d29 100644 (file)
@@ -268,6 +268,14 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                return NT_STATUS_NO_MEMORY;
        }
 
+       name_has_wildcard = ms_has_wild(name);
+
+       /* Wildcard not valid anywhere. */
+       if (name_has_wildcard && !allow_wcard_last_component) {
+               result = NT_STATUS_OBJECT_NAME_INVALID;
+               goto fail;
+       }
+
        /*
         * stat the name - if it exists then we are all done!
         */
@@ -374,12 +382,6 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
 
                name_has_wildcard = ms_has_wild(start);
 
-               /* Wildcard not valid anywhere. */
-               if (name_has_wildcard && !allow_wcard_last_component) {
-                       result = NT_STATUS_OBJECT_NAME_INVALID;
-                       goto fail;
-               }
-
                /* Wildcards never valid within a pathname. */
                if (name_has_wildcard && end) {
                        result = NT_STATUS_OBJECT_NAME_INVALID;