diff options
author | Jeremy Allison <jra@samba.org> | 2020-05-04 19:29:17 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2020-05-05 19:18:43 +0000 |
commit | 2992891e27810a9d7d1a93f9f274dc58a845d740 (patch) | |
tree | 305b1472239a38698b7eb4a81d748c6afc740ebf | |
parent | 8019b3d0af2eb9a309b2b7b7055fe3ddbd645728 (diff) | |
download | samba-2992891e27810a9d7d1a93f9f274dc58a845d740.tar.gz |
s3: smbd: Move the initialization of the filename and the call to canonicalize_snapshot_path() *before* zero-length string checks.
canonicalize_snapshot_path() may eat the incoming pathname in total
for SMB1, so we need to check after that call.
Fix the zero-length string check to look at state->smb_fname->base_name
instead of state->orig_path.
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
-rw-r--r-- | source3/smbd/filename.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 174b7b97dc3..daa4d9c3faa 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -990,6 +990,19 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx, return NT_STATUS_OBJECT_NAME_INVALID; } + /* Start with the full orig_path as given by the caller. */ + if (!(state->smb_fname->base_name = talloc_strdup(state->smb_fname, state->orig_path))) { + DBG_ERR("talloc_strdup failed\n"); + status = NT_STATUS_NO_MEMORY; + goto err; + } + + /* Canonicalize any @GMT- paths. */ + status = canonicalize_snapshot_path(state->smb_fname, ucf_flags, twrp); + if (!NT_STATUS_IS_OK(status)) { + goto err; + } + /* * If we trimmed down to a single '\0' character * then we should use the "." directory to avoid @@ -998,7 +1011,7 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx, * As we know this is valid we can return true here. */ - if (!*state->orig_path) { + if (state->smb_fname->base_name[0] == '\0') { if (!(state->smb_fname->base_name = talloc_strdup(state->smb_fname, "."))) { status = NT_STATUS_NO_MEMORY; goto err; @@ -1025,19 +1038,6 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx, goto err; } - /* Start with the full orig_path as given by the caller. */ - if (!(state->smb_fname->base_name = talloc_strdup(state->smb_fname, state->orig_path))) { - DBG_ERR("talloc_strdup failed\n"); - status = NT_STATUS_NO_MEMORY; - goto err; - } - - /* Canonicalize any @GMT- paths. */ - status = canonicalize_snapshot_path(state->smb_fname, ucf_flags, twrp); - if (!NT_STATUS_IS_OK(status)) { - goto err; - } - /* * Large directory fix normalization. If we're case sensitive, and * the case preserving parameters are set to "no", normalize the case of |