summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-09-29 01:27:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:04:47 -0500
commit4850bc63104f5f2945d9e91cfbd99773a5bc570f (patch)
tree5ce2cae56cefae44558a94772f320ee0179a4454 /source3/smbd
parent93bbaac16636c86c2a0c8c61fbbfd1a5c63f6f5a (diff)
downloadsamba-4850bc63104f5f2945d9e91cfbd99773a5bc570f.tar.gz
samba-4850bc63104f5f2945d9e91cfbd99773a5bc570f.tar.bz2
samba-4850bc63104f5f2945d9e91cfbd99773a5bc570f.zip
r10600: Fix bug #2769 (mangle filenames ending in a space)
and an old bug where mangle mathod hash wasn't mangling file names with more than one dot which also end in a dot. Jeremy. (This used to be commit 105e38847dc0078951abcda16808590ccc363b00)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/mangle_hash.c20
-rw-r--r--source3/smbd/mangle_hash2.c6
2 files changed, 18 insertions, 8 deletions
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 093b60b042..30befd2c84 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -158,6 +158,7 @@ static NTSTATUS mangle_get_prefix(const smb_ucs2_t *ucs2_string, smb_ucs2_t **pr
static NTSTATUS is_valid_name(const smb_ucs2_t *fname, BOOL allow_wildcards, BOOL only_8_3)
{
smb_ucs2_t *str, *p;
+ size_t num_ucs2_chars;
NTSTATUS ret = NT_STATUS_OK;
if (!fname || !*fname)
@@ -177,17 +178,22 @@ static NTSTATUS is_valid_name(const smb_ucs2_t *fname, BOOL allow_wildcards, BOO
if (!NT_STATUS_IS_OK(ret))
return ret;
- str = strdup_w(fname);
- p = strchr_w(str, UCS2_CHAR('.'));
- if (p && p[1] == UCS2_CHAR(0)) {
- /* Name cannot end in '.' */
- SAFE_FREE(str);
+ /* Name can't end in '.' or ' ' */
+ num_ucs2_chars = strlen_w(fname);
+ if (fname[num_ucs2_chars-1] == UCS2_CHAR('.') || fname[num_ucs2_chars-1] == UCS2_CHAR(' ')) {
return NT_STATUS_UNSUCCESSFUL;
}
- if (p)
+
+ str = strdup_w(fname);
+
+ /* Truncate copy after the first dot. */
+ p = strchr_w(str, UCS2_CHAR('.'));
+ if (p) {
*p = 0;
+ }
+
strupper_w(str);
- p = &(str[1]);
+ p = &str[1];
switch(str[0])
{
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index e44aaf17e7..613dda9a16 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -445,6 +445,7 @@ static BOOL is_reserved_name(const char *name)
/*
See if a filename is a legal long filename.
A filename ending in a '.' is not legal unless it's "." or "..". JRA.
+ A filename ending in ' ' is not legal either. See bug id #2769.
*/
static BOOL is_legal_name(const char *name)
@@ -480,6 +481,10 @@ static BOOL is_legal_name(const char *name)
} else {
alldots = False;
}
+ if ((name[0] == ' ') && (name[1] == '\0')) {
+ /* Can't end in ' ' */
+ return False;
+ }
name++;
}
@@ -491,7 +496,6 @@ static BOOL is_legal_name(const char *name)
if (dot_pos[1] == '\0')
return False;
}
-
return True;
}