]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: squash check_path_syntax() variants
authorRalph Boehme <slow@samba.org>
Fri, 31 Mar 2023 09:44:00 +0000 (11:44 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 31 Mar 2023 21:21:57 +0000 (21:21 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Ralph Böhme <slow@samba.org>
Autobuild-Date(master): Fri Mar 31 21:21:57 UTC 2023 on atb-devel-224

source3/smbd/msdfs.c
source3/smbd/proto.h
source3/smbd/smb1_reply.c
source3/smbd/smb2_create.c
source3/smbd/smb2_reply.c
source3/smbd/smb2_trans2.c

index a0b59da1fcf4fbfd832c2b6db8d7ddd8c1025230..dfb801a3f553a1b1972e15ac823bc87eb862660c 100644 (file)
@@ -55,7 +55,7 @@
      \pathname.
 
  If returned, remainingpath is untouched. Caller must call
- check_path_syntaxXXX() on it.
+ check_path_syntax() on it.
 
  Called by all non-fileserver processing (DFS RPC, FSCTL_DFS_GET_REFERRALS)
  etc. Errors out on any inconsistency in the path.
@@ -947,7 +947,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
        }
 
        /* Path referrals are always non-POSIX. */
-       status = check_path_syntax(reqpath);
+       status = check_path_syntax(reqpath, false);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
                return status;
@@ -1194,7 +1194,7 @@ bool create_junction(TALLOC_CTX *ctx,
        }
 
        /* Junction create paths are always non-POSIX. */
-       status = check_path_syntax(reqpath);
+       status = check_path_syntax(reqpath, false);
        if (!NT_STATUS_IS_OK(status)) {
                return false;
        }
index fafbdf3b787f2be9601b745e350d4eb6d4cc2f56..c5c0c1618678cce93e5daee644495a683dfbd9f2 100644 (file)
@@ -928,10 +928,7 @@ bool disk_quotas(connection_struct *conn, struct smb_filename *fname,
 
 /* The following definitions come from smbd/smb2_reply.c  */
 
-NTSTATUS check_path_syntax(char *path);
-NTSTATUS check_path_syntax_posix(char *path);
-NTSTATUS check_path_syntax_smb2(char *path);
-NTSTATUS check_path_syntax_smb2_posix(char *path);
+NTSTATUS check_path_syntax(char *path, bool posix);
 NTSTATUS smb1_strip_dfs_path(TALLOC_CTX *mem_ctx,
                             uint32_t *ucf_flags,
                             char **in_path);
index 3fc2cc8e793752e64f40bacfeaa1c588c8e2547a..7921d6b261ba4229ba88f8919fc9e8d04c71c279 100644 (file)
@@ -73,7 +73,7 @@ bool check_fsp_open(connection_struct *conn, struct smb_request *req,
 /****************************************************************************
  SMB1 version of smb2_strip_dfs_path()
  Differs from SMB2 in that all Windows path separator '\' characters
- have already been converted to '/' by check_path_syntax_internal().
+ have already been converted to '/' by check_path_syntax().
 ****************************************************************************/
 
 NTSTATUS smb1_strip_dfs_path(TALLOC_CTX *mem_ctx,
index c9f2f7e03138d01c0511ab8c363b51228913ce48..93c345f5809a48e5954561427db28a599e4e5c0d 100644 (file)
@@ -512,11 +512,7 @@ static NTSTATUS smbd_smb2_create_durable_lease_check(struct smb_request *smb1req
        }
 
        /* This also converts '\' to '/' */
-       if (is_posix) {
-               status = check_path_syntax_smb2_posix(filename);
-       } else {
-               status = check_path_syntax_smb2(filename);
-       }
+       status = check_path_syntax(filename, is_posix);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(filename);
                return status;
@@ -1054,12 +1050,8 @@ static struct tevent_req *smbd_smb2_create_send(TALLOC_CTX *mem_ctx,
 
        is_posix = (state->posx != NULL);
 
-       if (is_posix) {
-               status = check_path_syntax_smb2_posix(state->fname);
-       } else {
-               /* convert '\\' into '/' */
-               status = check_path_syntax_smb2(state->fname);
-       }
+       /* convert '\\' into '/' */
+       status = check_path_syntax(state->fname, is_posix);
        if (tevent_req_nterror(req, status)) {
                return tevent_req_post(req, state->ev);
        }
index 85d057386d5258075a41a26845798ece135a8ecf..ba0b38c7d6f57cdf3d3fffe6b1161eb581bd6713 100644 (file)
@@ -63,8 +63,7 @@
 /* Custom version for processing POSIX paths. */
 #define IS_PATH_SEP(c,posix_only) ((c) == '/' || (!(posix_only) && (c) == '\\'))
 
-static NTSTATUS check_path_syntax_internal(char *path,
-                                          bool posix_path)
+NTSTATUS check_path_syntax(char *path, bool posix_path)
 {
        char *d = path;
        const char *s = path;
@@ -209,7 +208,7 @@ static NTSTATUS check_path_syntax_internal(char *path,
                                        *d++ = *s++;
                                        break;
                                default:
-                                       DEBUG(0,("check_path_syntax_internal: character length assumptions invalid !\n"));
+                                       DBG_ERR("character length assumptions invalid !\n");
                                        *d = '\0';
                                        return NT_STATUS_INVALID_PARAMETER;
                        }
@@ -222,37 +221,6 @@ static NTSTATUS check_path_syntax_internal(char *path,
        return ret;
 }
 
-/****************************************************************************
- Ensure we check the path in *exactly* the same way as W2K for regular pathnames.
- No wildcards allowed.
-****************************************************************************/
-
-NTSTATUS check_path_syntax(char *path)
-{
-       return check_path_syntax_internal(path, false);
-}
-
-/****************************************************************************
- Check the path for a POSIX client.
- We're assuming here that '/' is not the second byte in any multibyte char
- set (a safe assumption).
-****************************************************************************/
-
-NTSTATUS check_path_syntax_posix(char *path)
-{
-       return check_path_syntax_internal(path, true);
-}
-
-NTSTATUS check_path_syntax_smb2(char *path)
-{
-       return check_path_syntax_internal(path, false);
-}
-
-NTSTATUS check_path_syntax_smb2_posix(char *path)
-{
-       return check_path_syntax_internal(path, true);
-}
-
 /****************************************************************************
  SMB2-only code to strip an MSDFS prefix from an incoming pathname.
 ****************************************************************************/
@@ -434,11 +402,7 @@ static size_t srvstr_get_path_internal(TALLOC_CTX *ctx,
 
   local_path:
 
-       if (posix_pathnames) {
-               *err = check_path_syntax_posix(dst);
-       } else {
-               *err = check_path_syntax(dst);
-       }
+       *err = check_path_syntax(dst, posix_pathnames);
 
        return ret;
 }
index 5c8cef1bf72834c6052eb27a36b8b17d75a3d0b6..c32e0e52e02b88f04d33e841b546b51e93ea3ab1 100644 (file)
@@ -4445,11 +4445,8 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
        req->flags2 &= ~FLAGS2_DFS_PATHNAMES;
        ucf_flags &= ~UCF_DFS_PATHNAME;
 
-       if (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) {
-               status = check_path_syntax_smb2_posix(newname);
-       } else {
-               status = check_path_syntax_smb2(newname);
-       }
+       status = check_path_syntax(newname,
+                       fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }
@@ -4560,11 +4557,8 @@ static NTSTATUS smb2_file_link_information(connection_struct *conn,
        req->flags2 &= ~FLAGS2_DFS_PATHNAMES;
        ucf_flags &= ~UCF_DFS_PATHNAME;
 
-       if (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) {
-               status = check_path_syntax_smb2_posix(newname);
-       } else {
-               status = check_path_syntax_smb2(newname);
-       }
+       status = check_path_syntax(newname,
+                       fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH);
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }