summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/process.c19
-rw-r--r--source3/smbd/reply.c4
-rw-r--r--source3/smbd/trans2.c21
3 files changed, 25 insertions, 19 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index b3cd2f26c8..e4d15d87d6 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -37,7 +37,8 @@ SIG_ATOMIC_T got_sig_term = 0;
extern bool global_machine_password_needs_changing;
extern int max_send;
-static void construct_reply_common(const char *inbuf, char *outbuf);
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+ char *outbuf);
/* Accessor function for smb_read_error for smbd functions. */
@@ -1248,8 +1249,9 @@ static const struct smb_message_struct {
allocate and initialize a reply packet
********************************************************************/
-bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
- uint8_t num_words, uint32_t num_bytes)
+static bool create_outbuf(TALLOC_CTX *mem_ctx, struct smb_request *req,
+ const char *inbuf, char **outbuf, uint8_t num_words,
+ uint32_t num_bytes)
{
/*
* Protect against integer wrap
@@ -1270,7 +1272,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
return false;
}
- construct_reply_common(inbuf, *outbuf);
+ construct_reply_common(req, inbuf, *outbuf);
srv_set_message(*outbuf, num_words, num_bytes, false);
/*
* Zero out the word area, the caller has to take care of the bcc area
@@ -1286,7 +1288,7 @@ bool create_outbuf(TALLOC_CTX *mem_ctx, const char *inbuf, char **outbuf,
void reply_outbuf(struct smb_request *req, uint8 num_words, uint32 num_bytes)
{
char *outbuf;
- if (!create_outbuf(req, (char *)req->inbuf, &outbuf, num_words,
+ if (!create_outbuf(req, req, (char *)req->inbuf, &outbuf, num_words,
num_bytes)) {
smb_panic("could not allocate output buffer\n");
}
@@ -1592,11 +1594,12 @@ void remove_from_common_flags2(uint32 v)
common_flags2 &= ~v;
}
-static void construct_reply_common(const char *inbuf, char *outbuf)
+static void construct_reply_common(struct smb_request *req, const char *inbuf,
+ char *outbuf)
{
srv_set_message(outbuf,0,0,false);
- SCVAL(outbuf,smb_com,CVAL(inbuf,smb_com));
+ SCVAL(outbuf, smb_com, req->cmd);
SIVAL(outbuf,smb_rcls,0);
SCVAL(outbuf,smb_flg, FLAG_REPLY | (CVAL(inbuf,smb_flg) & FLAG_CASELESS_PATHNAMES));
SSVAL(outbuf,smb_flg2,
@@ -1612,7 +1615,7 @@ static void construct_reply_common(const char *inbuf, char *outbuf)
void construct_reply_common_req(struct smb_request *req, char *outbuf)
{
- construct_reply_common((char *)req->inbuf, outbuf);
+ construct_reply_common(req, (char *)req->inbuf, outbuf);
}
/****************************************************************************
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 9f7a1896b8..b8be3ed304 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5515,7 +5515,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
}
if(replace_if_exists && dst_exists) {
- if (is_ntfs_stream_name(newname)) {
+ /* Ensure both or neither are stream names. */
+ if (is_ntfs_stream_name(fsp->fsp_name) !=
+ is_ntfs_stream_name(newname)) {
return NT_STATUS_INVALID_PARAMETER;
}
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 606e656795..27e29515e4 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -5372,6 +5372,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
char *newname = NULL;
char *base_name = NULL;
bool dest_has_wcard = False;
+ SMB_STRUCT_STAT sbuf;
+ char *newname_last_component = NULL;
NTSTATUS status = NT_STATUS_OK;
char *p;
TALLOC_CTX *ctx = talloc_tos();
@@ -5380,6 +5382,8 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_INVALID_PARAMETER;
}
+ ZERO_STRUCT(sbuf);
+
overwrite = (CVAL(pdata,0) ? True : False);
root_fid = IVAL(pdata,4);
len = IVAL(pdata,8);
@@ -5413,6 +5417,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
}
if (fsp && fsp->base_fsp) {
+ /* newname must be a stream name. */
if (newname[0] != ':') {
return NT_STATUS_NOT_SUPPORTED;
}
@@ -5423,6 +5428,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
return NT_STATUS_NO_MEMORY;
}
} else {
+ /* newname must *not* be a stream name. */
if (is_ntfs_stream_name(newname)) {
return NT_STATUS_NOT_SUPPORTED;
}
@@ -5448,18 +5454,11 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
if (!base_name) {
return NT_STATUS_NO_MEMORY;
}
- }
-
- if (fsp) {
- SMB_STRUCT_STAT sbuf;
- char *newname_last_component = NULL;
-
- ZERO_STRUCT(sbuf);
status = unix_convert(ctx, conn, newname, False,
- &newname,
- &newname_last_component,
- &sbuf);
+ &newname,
+ &newname_last_component,
+ &sbuf);
/* If an error we expect this to be
* NT_STATUS_OBJECT_PATH_NOT_FOUND */
@@ -5469,7 +5468,9 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
status)) {
return status;
}
+ }
+ if (fsp) {
DEBUG(10,("smb_file_rename_information: SMB_FILE_RENAME_INFORMATION (fnum %d) %s -> %s\n",
fsp->fnum, fsp->fsp_name, base_name ));
status = rename_internals_fsp(conn, fsp, base_name,