summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}