summaryrefslogtreecommitdiff
path: root/libdiskfs
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 /libdiskfs
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 'libdiskfs')
-rw-r--r--libdiskfs/dir-lookup.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 8b986e49..c50970d2 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -421,24 +421,25 @@ diskfs_S_dir_lookup (struct protid *dircred,
memcpy (pathbuf + np->dn_stat.st_size + 1,
nextname, nextnamelen - 1);
}
- pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
+ if (mustbedir)
+ {
+ pathbuf[nextnamelen + np->dn_stat.st_size] = '/';
+ pathbuf[nextnamelen + np->dn_stat.st_size + 1] = '\0';
+ }
+ else
+ pathbuf[nextnamelen + np->dn_stat.st_size] = '\0';
if (pathbuf[0] == '/')
{
/* Punt to the caller. */
*retry = FS_RETRY_MAGICAL;
*returned_port = MACH_PORT_NULL;
- memcpy (retryname, pathbuf,
- nextnamelen + np->dn_stat.st_size + 1);
- if (mustbedir)
- {
- retryname[nextnamelen + np->dn_stat.st_size] = '/';
- retryname[nextnamelen + np->dn_stat.st_size + 1] = '\0';
- }
+ strcpy (retryname, pathbuf);
goto out;
}
path = pathbuf;
+ mustbedir = 0;
}
if (lastcomp)