summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-09 00:13:46 +0200
committerJustus Winter <justus@gnupg.org>2017-09-12 10:41:35 +0200
commit074f0ea9799b2fa5297eb120d68e0a97cf1b40ac (patch)
tree232d67a67fe1ec02978d174a3f4dc12a68df49c3
parent5fef1b7f22ec0ee3730b80bbf972dbf9a8995091 (diff)
Normalize path of translators.
* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Strip trailing slashes. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Likewise.
-rw-r--r--libdiskfs/dir-lookup.c8
-rw-r--r--libnetfs/dir-lookup.c8
2 files changed, 14 insertions, 2 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 63bba78e..a0c368b1 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -286,6 +286,7 @@ diskfs_S_dir_lookup (struct protid *dircred,
{
char *translator_path = strdupa (relpath);
+ char *end;
char *complete_path;
if (nextname != NULL)
{
@@ -293,12 +294,17 @@ diskfs_S_dir_lookup (struct protid *dircred,
NEXTNAME points to the next component, locate
the end of the current component and use it
to trim TRANSLATOR_PATH. */
- char *end = nextname;
+ end = nextname;
while (*end != 0)
end--;
translator_path[end - filename_start] = '\0';
}
+ /* Trim trailing slashes. */
+ end = &translator_path[strlen (translator_path) - 1];
+ while (*end == '/' && end >= translator_path)
+ *end = '\0', end--;
+
if (dircred->po->path == NULL
|| !strcmp (dircred->po->path,"."))
/* dircred is the root directory. */
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index 321ee6e1..bfac2acd 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -277,6 +277,7 @@ netfs_S_dir_lookup (struct protid *dircred,
{
char *translator_path = strdupa (relpath);
+ char *end;
char *complete_path;
if (nextname != NULL)
{
@@ -284,12 +285,17 @@ netfs_S_dir_lookup (struct protid *dircred,
NEXTNAME points to the next component, locate
the end of the current component and use it
to trim TRANSLATOR_PATH. */
- char *end = nextname;
+ end = nextname;
while (*end != 0)
end--;
translator_path[end - filename_start] = '\0';
}
+ /* Trim trailing slashes. */
+ end = &translator_path[strlen (translator_path) - 1];
+ while (*end == '/' && end >= translator_path)
+ *end = '\0', end--;
+
if (dircred->po->path == NULL
|| !strcmp (dircred->po->path,"."))
/* dircred is the root directory. */