Index: smbd/mangle_hash.c =================================================================== --- smbd/mangle_hash.c (revision 10599) +++ smbd/mangle_hash.c (working copy) @@ -158,6 +158,7 @@ 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 @@ if (!NT_STATUS_IS_OK(ret)) return ret; + /* 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; + } + str = strdup_w(fname); + + /* Truncate copy after the first dot. */ p = strchr_w(str, UCS2_CHAR('.')); - if (p && p[1] == UCS2_CHAR(0)) { - /* Name cannot end in '.' */ - SAFE_FREE(str); - return NT_STATUS_UNSUCCESSFUL; + if (p) { + *p = 0; } - if (p) - *p = 0; + strupper_w(str); - p = &(str[1]); + p = &str[1]; switch(str[0]) { Index: smbd/mangle_hash2.c =================================================================== --- smbd/mangle_hash2.c (revision 10599) +++ smbd/mangle_hash2.c (working copy) @@ -445,6 +445,7 @@ /* 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 @@ } else { alldots = False; } + if ((name[0] == ' ') && (name[1] == '\0')) { + /* Can't end in ' ' */ + return False; + } name++; } @@ -491,7 +496,6 @@ if (dot_pos[1] == '\0') return False; } - return True; }