summaryrefslogtreecommitdiffstats
path: root/source/smbd/open.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-07-29 17:34:20 +0000
committerJeremy Allison <jra@samba.org>2003-07-29 17:34:20 +0000
commit7f111e545d198faa5fa89f6d360db0d5c32a8bd7 (patch)
tree08decb493c21a658e4efc83a27421ae36a87c29e /source/smbd/open.c
parente8425df77c2e917c819592d93833a164ee3b5338 (diff)
downloadsamba-7f111e545d198faa5fa89f6d360db0d5c32a8bd7.tar.gz
samba-7f111e545d198faa5fa89f6d360db0d5c32a8bd7.tar.xz
samba-7f111e545d198faa5fa89f6d360db0d5c32a8bd7.zip
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.
Diffstat (limited to 'source/smbd/open.c')
-rw-r--r--source/smbd/open.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/source/smbd/open.c b/source/smbd/open.c
index 8f839830236..5f49640aa49 100644
--- a/source/smbd/open.c
+++ b/source/smbd/open.c
@@ -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) ));