summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2023-03-31 11:44:00 +0200
committerRalph Boehme <slow@samba.org>2023-03-31 21:21:57 +0000
commit47f401095ea723cbca6a8fc1a841465a32852cdc (patch)
tree0354370142971881ced18bed0cd5fc52eca9425b /source3
parent1d220e3170b1eb2afbff48d0148e30f8cec9fba0 (diff)
downloadsamba-47f401095ea723cbca6a8fc1a841465a32852cdc.tar.gz
smbd: squash check_path_syntax() variants
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
Diffstat (limited to 'source3')
-rw-r--r--source3/smbd/msdfs.c6
-rw-r--r--source3/smbd/proto.h5
-rw-r--r--source3/smbd/smb1_reply.c2
-rw-r--r--source3/smbd/smb2_create.c14
-rw-r--r--source3/smbd/smb2_reply.c42
-rw-r--r--source3/smbd/smb2_trans2.c14
6 files changed, 15 insertions, 68 deletions
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index a0b59da1fcf..dfb801a3f55 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -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;
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index fafbdf3b787..c5c0c161867 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -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);
diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c
index 3fc2cc8e793..7921d6b261b 100644
--- a/source3/smbd/smb1_reply.c
+++ b/source3/smbd/smb1_reply.c
@@ -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,
diff --git a/source3/smbd/smb2_create.c b/source3/smbd/smb2_create.c
index c9f2f7e0313..93c345f5809 100644
--- a/source3/smbd/smb2_create.c
+++ b/source3/smbd/smb2_create.c
@@ -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);
}
diff --git a/source3/smbd/smb2_reply.c b/source3/smbd/smb2_reply.c
index 85d057386d5..ba0b38c7d6f 100644
--- a/source3/smbd/smb2_reply.c
+++ b/source3/smbd/smb2_reply.c
@@ -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;
}
@@ -223,37 +222,6 @@ static NTSTATUS check_path_syntax_internal(char *path,
}
/****************************************************************************
- 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;
}
diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c
index 5c8cef1bf72..c32e0e52e02 100644
--- a/source3/smbd/smb2_trans2.c
+++ b/source3/smbd/smb2_trans2.c
@@ -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;
}