summaryrefslogtreecommitdiff
path: root/libnetfs
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2016-02-28 01:52:11 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2016-02-28 01:56:11 +0100
commit6e8e837864d4e24c2fdb4d90e8eb262ded78c3a8 (patch)
tree47022b7fe9e8344ad1c1765e15122067072f0fba /libnetfs
parenteeeb27ee14064dff84c833b4359d43d9869a9342 (diff)
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.
Diffstat (limited to 'libnetfs')
-rw-r--r--libnetfs/dir-lookup.c11
1 files changed, 9 insertions, 2 deletions
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;