summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/filename.c4
-rw-r--r--source3/smbd/lanman.c2
-rw-r--r--source3/smbd/msdfs.c2
-rw-r--r--source3/smbd/nttrans.c24
-rw-r--r--source3/smbd/reply.c37
-rw-r--r--source3/smbd/trans2.c22
6 files changed, 49 insertions, 42 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index 27f17f9628..f15c107711 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -107,7 +107,8 @@ stat struct will be filled with zeros (and this can be detected by checking
for nlinks = 0, which can never be true for any file).
****************************************************************************/
-NTSTATUS unix_convert(connection_struct *conn,
+NTSTATUS unix_convert(TALLOC_CTX *ctx,
+ connection_struct *conn,
const char *orig_path,
BOOL allow_wcard_last_component,
char **pp_conv_path,
@@ -121,7 +122,6 @@ NTSTATUS unix_convert(connection_struct *conn,
BOOL component_was_mangled = False;
BOOL name_has_wildcard = False;
NTSTATUS result;
- TALLOC_CTX *ctx = talloc_tos();
SET_STAT_INVALID(*pst);
*pp_conv_path = NULL;
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c
index 37fcc658db..87cbc9183e 100644
--- a/source3/smbd/lanman.c
+++ b/source3/smbd/lanman.c
@@ -415,7 +415,7 @@ static void PackDriverData(struct pack_desc* desc)
SIVAL(drivdata,0,sizeof drivdata); /* cb */
SIVAL(drivdata,4,1000); /* lVersion */
memset(drivdata+8,0,32); /* szDeviceName */
- push_ascii(drivdata+8,"NULL",-1, STR_TERMINATE);
+ push_ascii(drivdata+8,"NULL",32, STR_TERMINATE);
PACKl(desc,"l",drivdata,sizeof drivdata); /* pDriverData */
}
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index 5cbe8c68ac..1917eb4d10 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -476,7 +476,7 @@ static NTSTATUS dfs_path_lookup(TALLOC_CTX *ctx,
* think this is needed. JRA.
*/
- status = unix_convert(conn, pdp->reqpath, search_flag, &localpath,
+ status = unix_convert(ctx, conn, pdp->reqpath, search_flag, &localpath,
NULL, &sbuf);
if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status,
NT_STATUS_OBJECT_PATH_NOT_FOUND)) {
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index 452533629c..14a11c3fe3 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -745,7 +745,7 @@ void reply_ntcreate_and_X(connection_struct *conn,
file_attributes &= ~FILE_FLAG_POSIX_SEMANTICS;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(case_state);
reply_nterror(req, status);
@@ -1479,7 +1479,7 @@ static void call_nt_transact_create(connection_struct *conn,
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(case_state);
reply_nterror(req, status);
@@ -1817,11 +1817,12 @@ void reply_ntcancel(connection_struct *conn, struct smb_request *req)
Copy a file.
****************************************************************************/
-static NTSTATUS copy_internals(connection_struct *conn,
- struct smb_request *req,
- const char *oldname_in,
- const char *newname_in,
- uint32 attrs)
+static NTSTATUS copy_internals(TALLOC_CTX *ctx,
+ connection_struct *conn,
+ struct smb_request *req,
+ const char *oldname_in,
+ const char *newname_in,
+ uint32 attrs)
{
SMB_STRUCT_STAT sbuf1, sbuf2;
char *oldname = NULL;
@@ -1841,7 +1842,7 @@ static NTSTATUS copy_internals(connection_struct *conn,
return NT_STATUS_MEDIA_WRITE_PROTECTED;
}
- status = unix_convert(conn, oldname_in, False, &oldname,
+ status = unix_convert(ctx, conn, oldname_in, False, &oldname,
&last_component_oldname, &sbuf1);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -1862,7 +1863,7 @@ static NTSTATUS copy_internals(connection_struct *conn,
return NT_STATUS_NO_SUCH_FILE;
}
- status = unix_convert(conn, newname_in, False, &newname,
+ status = unix_convert(ctx, conn, newname_in, False, &newname,
&last_component_newname, &sbuf2);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -2058,7 +2059,8 @@ void reply_ntrename(connection_struct *conn, struct smb_request *req)
/* No wildcards. */
status = NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
} else {
- status = hardlink_internals(conn,
+ status = hardlink_internals(ctx,
+ conn,
oldname,
newname);
}
@@ -2068,7 +2070,7 @@ void reply_ntrename(connection_struct *conn, struct smb_request *req)
/* No wildcards. */
status = NT_STATUS_OBJECT_PATH_SYNTAX_BAD;
} else {
- status = copy_internals(conn, req, oldname,
+ status = copy_internals(ctx, conn, req, oldname,
newname, attrs);
}
break;
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index b94c91fe8e..d6813bef80 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -879,7 +879,7 @@ void reply_checkpath(connection_struct *conn, struct smb_request *req)
DEBUG(3,("reply_checkpath %s mode=%d\n", name, (int)SVAL(req->inbuf,smb_vwv0)));
- status = unix_convert(conn, name, False, &name, NULL, &sbuf);
+ status = unix_convert(ctx, conn, name, False, &name, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
goto path_err;
}
@@ -986,7 +986,7 @@ void reply_getatr(connection_struct *conn, struct smb_request *req)
size = 0;
mtime = 0;
} else {
- status = unix_convert(conn, fname, False, &fname, NULL,&sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL,&sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBgetatr);
@@ -1081,7 +1081,7 @@ void reply_setatr(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBsetatr);
@@ -1107,7 +1107,7 @@ void reply_setatr(connection_struct *conn, struct smb_request *req)
mode = SVAL(req->inbuf,smb_vwv0);
mtime = srv_make_unix_date3(req->inbuf+smb_vwv1);
-
+
if (mode != FILE_ATTRIBUTE_NORMAL) {
if (VALID_STAT_OF_DIR(sbuf))
mode |= aDIR;
@@ -1279,7 +1279,8 @@ void reply_search(connection_struct *conn, struct smb_request *req)
if (status_len == 0) {
SMB_STRUCT_STAT sbuf;
- nt_status = unix_convert(conn, path, True, &directory, NULL, &sbuf);
+ nt_status = unix_convert(ctx, conn, path, True,
+ &directory, NULL, &sbuf);
if (!NT_STATUS_IS_OK(nt_status)) {
reply_nterror(req, nt_status);
END_PROFILE(SMBsearch);
@@ -1612,13 +1613,13 @@ void reply_open(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBopen);
return;
}
-
+
status = check_name(conn, fname);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
@@ -1776,7 +1777,7 @@ void reply_open_and_X(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBopenX);
@@ -1996,7 +1997,7 @@ void reply_mknew(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBcreate);
@@ -2132,7 +2133,7 @@ void reply_ctemp(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBctemp);
@@ -2389,7 +2390,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req,
SMB_STRUCT_STAT sbuf;
TALLOC_CTX *ctx = talloc_tos();
- status = unix_convert(conn, name_in, has_wild, &name, NULL, &sbuf);
+ status = unix_convert(ctx, conn, name_in, has_wild, &name, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
@@ -4777,7 +4778,7 @@ void reply_mkdir(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, directory, False, &directory, NULL, &sbuf);
+ status = unix_convert(ctx, conn, directory, False, &directory, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBmkdir);
@@ -5045,7 +5046,7 @@ void reply_rmdir(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, directory, False, &directory,
+ status = unix_convert(ctx, conn, directory, False, &directory,
NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
@@ -5530,13 +5531,13 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx,
ZERO_STRUCT(sbuf1);
ZERO_STRUCT(sbuf2);
- status = unix_convert(conn, name_in, src_has_wild, &name,
+ status = unix_convert(ctx, conn, name_in, src_has_wild, &name,
&last_component_src, &sbuf1);
if (!NT_STATUS_IS_OK(status)) {
return status;
}
- status = unix_convert(conn, newname_in, dest_has_wild, &newname,
+ status = unix_convert(ctx, conn, newname_in, dest_has_wild, &newname,
&last_component_dest, &sbuf2);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -6120,14 +6121,16 @@ void reply_copy(connection_struct *conn, struct smb_request *req)
return;
}
- status = unix_convert(conn, name, source_has_wild, &name, NULL, &sbuf1);
+ status = unix_convert(ctx, conn, name, source_has_wild,
+ &name, NULL, &sbuf1);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBcopy);
return;
}
- status = unix_convert(conn, newname, dest_has_wild, &newname, NULL, &sbuf2);
+ status = unix_convert(ctx, conn, newname, dest_has_wild,
+ &newname, NULL, &sbuf2);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
END_PROFILE(SMBcopy);
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 63dcb06f5d..7af4bcee60 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -844,7 +844,7 @@ static void call_trans2open(connection_struct *conn,
/* XXXX we need to handle passed times, sattr and flags */
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
return;
@@ -1872,7 +1872,7 @@ close_if_end = %d requires_resume_key = %d level = 0x%x, max_data_bytes = %d\n",
return;
}
- ntstatus = unix_convert(conn, directory, True, &directory, NULL, &sbuf);
+ ntstatus = unix_convert(ctx, conn, directory, True, &directory, NULL, &sbuf);
if (!NT_STATUS_IS_OK(ntstatus)) {
reply_nterror(req, ntstatus);
return;
@@ -3664,7 +3664,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False, &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
return;
@@ -4430,7 +4430,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
code.
****************************************************************************/
-NTSTATUS hardlink_internals(connection_struct *conn,
+NTSTATUS hardlink_internals(TALLOC_CTX *ctx,
+ connection_struct *conn,
const char *oldname_in,
const char *newname_in)
{
@@ -4444,7 +4445,7 @@ NTSTATUS hardlink_internals(connection_struct *conn,
ZERO_STRUCT(sbuf1);
ZERO_STRUCT(sbuf2);
- status = unix_convert(conn, oldname_in, False, &oldname,
+ status = unix_convert(ctx, conn, oldname_in, False, &oldname,
&last_component_oldname, &sbuf1);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -4460,7 +4461,7 @@ NTSTATUS hardlink_internals(connection_struct *conn,
return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
- status = unix_convert(conn, newname_in, False, &newname,
+ status = unix_convert(ctx, conn, newname_in, False, &newname,
&last_component_newname, &sbuf2);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -4933,7 +4934,7 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
DEBUG(10,("smb_set_file_unix_hlink: SMB_SET_FILE_UNIX_LINK doing hard link %s -> %s\n",
fname, oldname));
- return hardlink_internals(conn, oldname, fname);
+ return hardlink_internals(ctx, conn, oldname, fname);
}
/****************************************************************************
@@ -5021,7 +5022,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
ZERO_STRUCT(sbuf);
- status = unix_convert(conn, newname, False,
+ status = unix_convert(ctx, conn, newname, False,
&newname,
&newname_last_component,
&sbuf);
@@ -6317,7 +6318,8 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
return;
}
- status = unix_convert(conn, fname, False, &fname, NULL, &sbuf);
+ status = unix_convert(ctx, conn, fname, False,
+ &fname, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
return;
@@ -6665,7 +6667,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
DEBUG(3,("call_trans2mkdir : name = %s\n", directory));
- status = unix_convert(conn, directory, False, &directory, NULL, &sbuf);
+ status = unix_convert(ctx, conn, directory, False, &directory, NULL, &sbuf);
if (!NT_STATUS_IS_OK(status)) {
reply_nterror(req, status);
return;