summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/smbd/filename.c34
-rw-r--r--source3/smbd/mangle_hash.c16
-rw-r--r--source3/smbd/mangle_hash2.c27
3 files changed, 45 insertions, 32 deletions
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index cb6a6d31a4..fa2ce893ad 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -38,35 +38,14 @@ static BOOL scan_directory(char *path, char *name,connection_struct *conn,BOOL d
Check if two filenames are equal.
This needs to be careful about whether we are case sensitive.
****************************************************************************/
+
static BOOL fname_equal(char *name1, char *name2)
{
- int l1 = strlen(name1);
- int l2 = strlen(name2);
-
- /* handle filenames ending in a single dot */
- if (l1-l2 == 1 && name1[l1-1] == '.' && lp_strip_dot())
- {
- BOOL ret;
- name1[l1-1] = 0;
- ret = fname_equal(name1,name2);
- name1[l1-1] = '.';
- return(ret);
- }
-
- if (l2-l1 == 1 && name2[l2-1] == '.' && lp_strip_dot())
- {
- BOOL ret;
- name2[l2-1] = 0;
- ret = fname_equal(name1,name2);
- name2[l2-1] = '.';
- return(ret);
- }
-
- /* now normal filename handling */
- if (case_sensitive)
- return(strcmp(name1,name2) == 0);
+ /* Normal filename handling */
+ if (case_sensitive)
+ return(strcmp(name1,name2) == 0);
- return(strequal(name1,name2));
+ return(strequal(name1,name2));
}
@@ -219,8 +198,7 @@ BOOL unix_convert(pstring name,connection_struct *conn,char *saved_last_componen
* sensitive then searching won't help.
*/
- if (case_sensitive && !mangle_is_mangled(name) &&
- !lp_strip_dot() && !use_mangled_map)
+ if (case_sensitive && !mangle_is_mangled(name) && !use_mangled_map)
return(False);
name_has_wildcard = ms_has_wild(start);
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index 1da66ff8e4..25f0c4dcc9 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -203,13 +203,24 @@ static NTSTATUS is_valid_name(const smb_ucs2_t *fname)
if (!fname || !*fname) return NT_STATUS_INVALID_PARAMETER;
- if (*fname == UCS2_CHAR('.')) return NT_STATUS_UNSUCCESSFUL;
+ /* . and .. are valid names. */
+ if (strcmp_wa(fname, ".")==0 || strcmp_wa(fname, "..")==0)
+ return NT_STATUS_OK;
+
+ /* Name cannot start with '.' */
+ if (*fname == UCS2_CHAR('.'))
+ return NT_STATUS_UNSUCCESSFUL;
ret = has_valid_chars(fname);
if (NT_STATUS_IS_ERR(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);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
if (p) *p = 0;
strupper_w(str);
p = &(str[1]);
@@ -731,6 +742,9 @@ static BOOL name_map(char *OutName, BOOL need83, BOOL cache83)
return False;
}
+ if( !need83 && NT_STATUS_IS_ERR(is_valid_name(OutName_ucs2)))
+ need83 = True;
+
/* check if it's already in 8.3 format */
if (need83 && !NT_STATUS_IS_OK(is_8_3_w(OutName_ucs2))) {
char *tmp = NULL;
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index 1c8b0689a1..1d81602641 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -254,8 +254,8 @@ static BOOL is_mangled_component(const char *name)
*/
static BOOL is_mangled(const char *name)
{
- char *p;
- char *s;
+ const char *p;
+ const char *s;
M_DEBUG(0,("is_mangled %s ?\n", name));
@@ -431,17 +431,38 @@ static BOOL is_reserved_name(const char *name)
}
/*
- see if a filename is a legal long filename
+ See if a filename is a legal long filename.
+ A filename ending in a '.' is not legal unless it's "." or "..". JRA.
*/
+
static BOOL is_legal_name(const char *name)
{
+ const char *dot_pos = NULL;
+ BOOL alldots = True;
+ size_t numdots = 0;
+
while (*name) {
if (FLAG_CHECK(name[0], FLAG_ILLEGAL)) {
return False;
}
+ if (name[0] == '.') {
+ dot_pos = name;
+ numdots++;
+ } else {
+ alldots = False;
+ }
name++;
}
+ if (dot_pos) {
+ if (alldots && (numdots == 1 || numdots == 2))
+ return True; /* . or .. is a valid name */
+
+ /* A valid long name cannot end in '.' */
+ if (dot_pos[1] == '\0')
+ return False;
+ }
+
return True;
}