summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2009-01-05 14:02:30 +0100
committerJelmer Vernooij <jelmer@samba.org>2009-01-05 14:02:30 +0100
commitde7dc2cec059305d28cc75a5347bfd88f3cb5c95 (patch)
treea286f235cbbbbaff06f83a32e55b0199da6dd8e4 /source3/smbd
parentca05542d3defe76c3bce48eaff1fc749821a976c (diff)
parent21b7b000fb53ac3025d0038cc551a47f9d4a743b (diff)
downloadsamba-de7dc2cec059305d28cc75a5347bfd88f3cb5c95.tar.gz
samba-de7dc2cec059305d28cc75a5347bfd88f3cb5c95.tar.bz2
samba-de7dc2cec059305d28cc75a5347bfd88f3cb5c95.zip
Merge branch 'master' of ssh://git.samba.org/data/git/samba
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/nttrans.c14
-rw-r--r--source3/smbd/reply.c25
-rw-r--r--source3/smbd/service.c4
3 files changed, 26 insertions, 17 deletions
diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
index b17aec80fa..3f33237f18 100644
--- a/source3/smbd/nttrans.c
+++ b/source3/smbd/nttrans.c
@@ -1310,13 +1310,6 @@ void reply_ntrename(struct smb_request *req)
return;
}
- if( is_ntfs_stream_name(oldname)) {
- /* Can't rename a stream. */
- reply_nterror(req, NT_STATUS_ACCESS_DENIED);
- END_PROFILE(SMBntrename);
- return;
- }
-
if (ms_has_wild(oldname)) {
reply_nterror(req, NT_STATUS_OBJECT_PATH_SYNTAX_BAD);
END_PROFILE(SMBntrename);
@@ -1364,6 +1357,13 @@ void reply_ntrename(struct smb_request *req)
return;
}
+ /* The new name must begin with a ':' if the old name is a stream. */
+ if (is_ntfs_stream_name(oldname) && (newname[0] != ':')) {
+ reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
+ END_PROFILE(SMBntrename);
+ return;
+ }
+
DEBUG(3,("reply_ntrename : %s -> %s\n",oldname,newname));
switch(rename_type) {
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 2133a30dc6..593558e399 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -5439,7 +5439,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
SMB_STRUCT_STAT sbuf, sbuf1;
NTSTATUS status = NT_STATUS_OK;
struct share_mode_lock *lck = NULL;
- bool dst_exists;
+ bool dst_exists, old_is_stream, new_is_stream;
ZERO_STRUCT(sbuf);
@@ -5508,6 +5508,18 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
return NT_STATUS_OK;
}
+ old_is_stream = is_ntfs_stream_name(fsp->fsp_name);
+ new_is_stream = is_ntfs_stream_name(newname);
+
+ /* Return the correct error code if both names aren't streams. */
+ if (!old_is_stream && new_is_stream) {
+ return NT_STATUS_OBJECT_NAME_INVALID;
+ }
+
+ if (old_is_stream && !new_is_stream) {
+ return NT_STATUS_INVALID_PARAMETER;
+ }
+
/*
* Have vfs_object_exist also fill sbuf1
*/
@@ -5519,18 +5531,11 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
return NT_STATUS_OBJECT_NAME_COLLISION;
}
- if(replace_if_exists && dst_exists) {
- /* 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;
- }
- }
-
if (dst_exists) {
struct file_id fileid = vfs_file_id_from_sbuf(conn, &sbuf1);
files_struct *dst_fsp = file_find_di_first(fileid);
- if (dst_fsp) {
+ /* The file can be open when renaming a stream */
+ if (dst_fsp && !new_is_stream) {
DEBUG(3, ("rename_internals_fsp: Target file open\n"));
return NT_STATUS_ACCESS_DENIED;
}
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 0dea615fb5..e90098fed0 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -235,6 +235,10 @@ static int load_registry_service(const char *servicename)
return -1;
}
+ if ((servicename == NULL) || (*servicename == '\0')) {
+ return -1;
+ }
+
if (strequal(servicename, GLOBAL_NAME)) {
return -2;
}