summaryrefslogtreecommitdiff
path: root/source/smbd/trans2.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-02-02 00:26:36 +0000
committerJeremy Allison <jra@samba.org>2002-02-02 00:26:36 +0000
commit3951b46286866bbd9ac39e1dc2088cd575b8e096 (patch)
tree9ef3d30bf5fcf66f06f69bd929b49be7d8fb4e5c /source/smbd/trans2.c
parent57511c6d7dc8c508acdea3a3e87c94426c9d13f3 (diff)
downloadsamba-3951b46286866bbd9ac39e1dc2088cd575b8e096.tar.gz
Sync for release.
Jeremy.
Diffstat (limited to 'source/smbd/trans2.c')
-rw-r--r--source/smbd/trans2.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/source/smbd/trans2.c b/source/smbd/trans2.c
index bfa304605f6..4c34603bff5 100644
--- a/source/smbd/trans2.c
+++ b/source/smbd/trans2.c
@@ -2186,17 +2186,30 @@ static int ensure_link_is_safe(connection_struct *conn, const char *link_dest_in
#else
pstring resolved_name;
#endif
+ fstring last_component;
pstring link_dest;
+ char *p;
BOOL bad_path = False;
SMB_STRUCT_STAT sbuf;
pstrcpy(link_dest, link_dest_in);
unix_convert(link_dest,conn,0,&bad_path,&sbuf);
+ p = strrchr(link_dest, '/');
+ if (p) {
+ fstrcpy(last_component, p+1);
+ *p = '\0';
+ } else {
+ fstrcpy(last_component, link_dest);
+ pstrcpy(link_dest, "./");
+ }
+
if (conn->vfs_ops.realpath(conn,dos_to_unix(link_dest,False),resolved_name) == NULL)
return -1;
pstrcpy(link_dest, unix_to_dos(resolved_name,False));
+ pstrcat(link_dest, "/");
+ pstrcat(link_dest, last_component);
if (*link_dest != '/') {
/* Relative path. */