diff options
Diffstat (limited to 'source/smbd/filename.c')
-rw-r--r-- | source/smbd/filename.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/source/smbd/filename.c b/source/smbd/filename.c index bdbcd81b644..601c488fc9c 100644 --- a/source/smbd/filename.c +++ b/source/smbd/filename.c @@ -27,7 +27,6 @@ #include "includes.h" -extern int DEBUGLEVEL; extern BOOL case_sensitive; extern BOOL case_preserve; extern BOOL short_case_preserve; @@ -293,7 +292,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, } else { pstring rest; - /* Stat failed - ensure we don't use it. */ + /* Stat failed - ensure we don't use it. */ ZERO_STRUCT(st); *rest = 0; @@ -330,7 +329,7 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, /* * Just the last part of the name doesn't exist. - * We may need to strupper() or strlower() it in case + * We may need to strupper() or strlower() it in case * this conversion is being used for file creation * purposes. If the filename is of mixed case then * don't normalise it. @@ -353,11 +352,14 @@ BOOL unix_convert(char *name,connection_struct *conn,char *saved_last_component, } /* - * Restore the rest of the string. + * Restore the rest of the string. If the string was mangled the size + * may have changed. */ if (end) { - pstrcpy(start+strlen(start)+1,rest); end = start + strlen(start); + pstrcat(start,"/"); + pstrcat(start,rest); + *end = '\0'; } } /* end else */ @@ -495,11 +497,25 @@ static BOOL scan_directory(char *path, char *name,connection_struct *conn,BOOL d if (*dname == '.' && (strequal(dname,".") || strequal(dname,".."))) continue; + /* + * dname here is the unmangled name. + */ pstrcpy(name2,dname); if (!name_map_mangle(name2,False,True,SNUM(conn))) continue; - if ((mangled && mangled_equal(name,name2)) || fname_equal(name, name2)) { + /* + * At this point name2 is the mangled name, dname is the unmangled name. + * name is either mangled or not, depending on the state of the "mangled" + * variable. JRA. + */ + + /* + * Check mangled name against mangled name, or unmangled name + * against unmangled name. + */ + + if ((mangled && mangled_equal(name,name2)) || fname_equal(name, dname)) { /* we've found the file, change it's name and return */ if (docache) DirCacheAdd(path,name,dname,SNUM(conn)); |