From 6e8e837864d4e24c2fdb4d90e8eb262ded78c3a8 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sun, 28 Feb 2016 01:52:11 +0100 Subject: Fix mustbedir mechanism for symlinks * libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): When following a symlink, if mustbedir is true, always append a slash to the symlink target, not only when the target is absolute. Reset mustbedir to 0 before continuing the lookup loop. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): When following a symlink, if mustbedir is true, append a slash to the symlink target. Reset mustbedir to 0 before continuing the lookup loop. * libtreefs/dir-lookup.c (_treefs_s_dir_lookup): Likewise. --- libnetfs/dir-lookup.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'libnetfs') diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c index 1fefd3ff..cbe29419 100644 --- a/libnetfs/dir-lookup.c +++ b/libnetfs/dir-lookup.c @@ -367,7 +367,7 @@ netfs_S_dir_lookup (struct protid *diruser, linklen = np->nn_stat.st_size; nextnamelen = nextname ? strlen (nextname) + 1 : 0; - newnamelen = nextnamelen + linklen + 1; + newnamelen = nextnamelen + linklen + 1 + 1; linkbuf = alloca (newnamelen); error = netfs_attempt_readlink (diruser->user, np, linkbuf); @@ -380,7 +380,13 @@ netfs_S_dir_lookup (struct protid *diruser, memcpy (linkbuf + linklen + 1, nextname, nextnamelen - 1); } - linkbuf[nextnamelen + linklen] = '\0'; + if (mustbedir) + { + linkbuf[nextnamelen + linklen] = '/'; + linkbuf[nextnamelen + linklen + 1] = '\0'; + } + else + linkbuf[nextnamelen + linklen] = '\0'; if (linkbuf[0] == '/') { @@ -392,6 +398,7 @@ netfs_S_dir_lookup (struct protid *diruser, } filename = linkbuf; + mustbedir = 0; if (lastcomp) { lastcomp = 0; -- cgit v1.2.3