} else {
pstring rest;
- /* Stat failed - ensure we don't use it. */
+ /* Stat failed - ensure we don't use it. */
ZERO_STRUCT(st);
*rest = 0;
/*
* 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.
}
/*
- * 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 */
if (!name_map_mangle(name2,False,True,SNUM(conn)))
continue;
- if ((mangled && mangled_equal(name,name2)) || fname_equal(name, name2)) {
+ 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));