summaryrefslogtreecommitdiff
path: root/source3/smbd/mangle_hash.c
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/mangle_hash.c
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/mangle_hash.c')
-rw-r--r--source3/smbd/mangle_hash.c20
1 files changed, 13 insertions, 7 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])
{