diff options
author | Jeremy Allison <jra@samba.org> | 2004-02-28 00:56:39 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2004-02-28 00:56:39 +0000 |
commit | cff0114f2b5965cfc49f39061305ff23fa4f3931 (patch) | |
tree | d27decd5045b5ff841d6315e4bfba191c52f46fd /source3/smbd/reply.c | |
parent | 499fec31b624a87dd40d6204afbdcd4c362d1575 (diff) | |
download | samba-cff0114f2b5965cfc49f39061305ff23fa4f3931.tar.gz samba-cff0114f2b5965cfc49f39061305ff23fa4f3931.tar.bz2 samba-cff0114f2b5965cfc49f39061305ff23fa4f3931.zip |
More gentest fixes. Fix up regression in IS_NAME_VALID and renames.
Jeremy.
(This used to be commit 2a457e2e28cd1f78778cb41fbb381883ced99592)
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r-- | source3/smbd/reply.c | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 643b7c2d08..836f95e179 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3357,16 +3357,20 @@ NTSTATUS rename_internals_fsp(connection_struct *conn, files_struct *fsp, char * pstring newname_last_component; NTSTATUS error = NT_STATUS_OK; BOOL dest_exists; + BOOL rcdest = True; ZERO_STRUCT(sbuf); - unix_convert(newname,conn,newname_last_component,&bad_path,&sbuf); + rcdest = unix_convert(newname,conn,newname_last_component,&bad_path,&sbuf); /* Quick check for "." and ".." */ - if (newname_last_component[0] == '.') { + if (!bad_path && newname_last_component[0] == '.') { if (!newname_last_component[1] || (newname_last_component[1] == '.' && !newname_last_component[2])) { return NT_STATUS_ACCESS_DENIED; } } + if (!rcdest && bad_path) { + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + } /* Ensure newname contains a '/' */ if(strrchr_m(newname,'/') == 0) { @@ -3472,6 +3476,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, BO int count=0; NTSTATUS error = NT_STATUS_OK; BOOL rc = True; + BOOL rcdest = True; SMB_STRUCT_STAT sbuf1, sbuf2; *directory = *mask = 0; @@ -3479,15 +3484,7 @@ NTSTATUS rename_internals(connection_struct *conn, char *name, char *newname, BO ZERO_STRUCT(sbuf1); ZERO_STRUCT(sbuf2); rc = unix_convert(name,conn,0,&bad_path1,&sbuf1); - unix_convert(newname,conn,newname_last_component,&bad_path2,&sbuf2); - - /* Quick check for "." and ".." */ - if (!bad_path2 && newname_last_component[0] == '.') { - if (!newname_last_component[1] || (newname_last_component[1] == '.' && !newname_last_component[2])) { - DEBUG(10,("rename_internals: newname_last_component = '.' or '..'\n")); - return NT_STATUS_ACCESS_DENIED; - } - } + rcdest = unix_convert(newname,conn,newname_last_component,&bad_path2,&sbuf2); /* * Split the old name into directory and last component @@ -3612,6 +3609,17 @@ directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n", return error; } + /* Quick check for "." and ".." */ + if (!bad_path2 && newname_last_component[0] == '.') { + if (!newname_last_component[1] || (newname_last_component[1] == '.' && !newname_last_component[2])) { + DEBUG(10,("rename_internals: newname_last_component = '.' or '..'\n")); + return NT_STATUS_ACCESS_DENIED; + } + } + if (!rcdest && bad_path2) { + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + } + error = can_rename(directory,conn,&sbuf1); if (!NT_STATUS_IS_OK(error)) { @@ -3661,6 +3669,17 @@ directory = %s, newname = %s, newname_last_component = %s, is_8_3 = %d\n", const char *dname; pstring destname; + /* Quick check for "." and ".." */ + if (!bad_path2 && newname_last_component[0] == '.') { + if (!newname_last_component[1] || (newname_last_component[1] == '.' && !newname_last_component[2])) { + DEBUG(10,("rename_internals: newname_last_component = '.' or '..'\n")); + return NT_STATUS_ACCESS_DENIED; + } + } + if (!rcdest && bad_path2) { + return NT_STATUS_OBJECT_PATH_NOT_FOUND; + } + if (check_name(directory,conn)) dirptr = OpenDir(conn, directory, True); |