mirror of
https://github.com/samba-team/samba.git
synced 2025-07-31 20:22:15 +03:00
Finish tridge's patch as referenced here :
make sure we don't allow the creation of directories containing wildcard characters. I've only put this in mkdir at the moment, but I suspect this will apply to all places that can create new filenames. We need to allow the opening of existing filenames that contain wildcards, but not allow the creation of new ones. Jeremy.
This commit is contained in:
@ -167,6 +167,14 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
|
||||
local_flags |= O_NONBLOCK;
|
||||
#endif
|
||||
|
||||
/* Don't create files with Microsoft wildcard characters. */
|
||||
if ((local_flags & O_CREAT) && !VALID_STAT(*psbuf) && ms_has_wild(fname)) {
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRinvalidname;
|
||||
unix_ERR_ntstatus = NT_STATUS_OBJECT_NAME_INVALID;
|
||||
return False;
|
||||
}
|
||||
|
||||
/* Actually do the open */
|
||||
fsp->fd = fd_open(conn, fname, local_flags, mode);
|
||||
if (fsp->fd == -1) {
|
||||
@ -1291,6 +1299,15 @@ files_struct *open_directory(connection_struct *conn, char *fname, SMB_STRUCT_ST
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ms_has_wild(fname)) {
|
||||
file_free(fsp);
|
||||
DEBUG(5,("open_directory: failing create on filename %s with wildcards\n", fname));
|
||||
unix_ERR_class = ERRDOS;
|
||||
unix_ERR_code = ERRinvalidname;
|
||||
unix_ERR_ntstatus = NT_STATUS_OBJECT_NAME_INVALID;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(vfs_MkDir(conn,fname, unix_mode(conn,aDIR, fname)) < 0) {
|
||||
DEBUG(2,("open_directory: unable to create %s. Error was %s\n",
|
||||
fname, strerror(errno) ));
|
||||
|
Reference in New Issue
Block a user