From 48eb635f31a09fa0822d95d3e895255ef8a6d5e2 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Fri, 5 Mar 2004 22:32:45 +0000 Subject: Several mb tidyups - getting ready to address the XXX_sub function. Jeremy. (This used to be commit 92c3ae3458177ec7f721598311a8ad04b2db5138) --- source3/smbd/vfs.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source3/smbd/vfs.c') diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 284e24e7b1..4f3234775a 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -863,8 +863,8 @@ BOOL reduce_name(connection_struct *conn, pstring s, const char *dir) DEBUG(3,("reduce_name [%s] [%s]\n",s,dir)); - /* remove any double slashes */ - all_string_sub(s,"//","/",0); + /* We know there are no double slashes as this comes from srvstr_get_path(). + and has gone through check_path_syntax(). JRA */ pstrcpy(base_name,s); p = strrchr_m(base_name,'/'); @@ -915,17 +915,19 @@ BOOL reduce_name(connection_struct *conn, pstring s, const char *dir) { size_t l = strlen(dir2); - if (dir2[l-1] == '/') + char *last_slash = strrchr_m(dir2, '/'); + + if (last_slash && (last_slash[1] == '\0')) l--; if (strncmp(newname,dir2,l) != 0) { vfs_ChDir(conn,wd); - DEBUG(2,("Bad access attempt? s=%s dir=%s newname=%s l=%d\n",s,dir2,newname,(int)l)); + DEBUG(2,("Bad access attempt: s=%s dir=%s newname=%s l=%d\n",s,dir2,newname,(int)l)); return(False); } if (!readlink_check(conn, dir, newname)) { - DEBUG(2, ("Bad access attemt? %s is a symlink outside the share path", s)); + DEBUG(2, ("Bad access attemt: %s is a symlink outside the share path", s)); return(False); } @@ -947,4 +949,3 @@ BOOL reduce_name(connection_struct *conn, pstring s, const char *dir) return(True); #endif } - -- cgit