aboutsummaryrefslogtreecommitdiffstats
path: root/pseudo_util.c
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2015-01-05 17:25:19 -0600
committerPeter Seebach <peter.seebach@windriver.com>2015-01-05 17:25:19 -0600
commit364c4a055477705a5370f59b9260226bb262a6db (patch)
treefde5f6d3baff7f5d5ba5ec10602141d6f68ae718 /pseudo_util.c
parent0dc29e7c67f25d0978a7da5cd8965514912c5b36 (diff)
downloadpseudo-364c4a055477705a5370f59b9260226bb262a6db.tar.gz
pseudo-364c4a055477705a5370f59b9260226bb262a6db.tar.bz2
pseudo-364c4a055477705a5370f59b9260226bb262a6db.zip
Try to handle trailing slashes
It turns out that "a/" is equivalent to "a/.", and that in particular it should fail when a is not a directory. Pseudo's been silently stripping them and this breaks things. Attempt to fix that, lightly tested.
Diffstat (limited to 'pseudo_util.c')
-rw-r--r--pseudo_util.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/pseudo_util.c b/pseudo_util.c
index e4e1fc8..9ff2587 100644
--- a/pseudo_util.c
+++ b/pseudo_util.c
@@ -624,12 +624,17 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel
char *newpath;
char *current;
char *effective_root;
+ int trailing_slash = 0;
if (!path) {
pseudo_diag("can't fix empty path.\n");
return 0;
}
pathlen = strlen(path);
+ /* a trailing slash has special meaning */
+ if (pathlen > 0 && path[pathlen - 1] == '/') {
+ trailing_slash = 1;
+ }
newpathlen = pathlen;
/* If the path starts with /, we don't care about base, UNLESS
* rootlen is non-zero, in which case we're doing a chroot thing
@@ -667,7 +672,7 @@ pseudo_fix_path(const char *base, const char *path, size_t rootlen, size_t basel
*/
if (pseudo_append_elements(&newpath, &effective_root, &newpathlen, &current, path, pathlen, leave_last) != -1) {
--current;
- if (*current == '/' && current > effective_root) {
+ if (*current == '/' && current > effective_root && !trailing_slash) {
*current = '\0';
}
pseudo_debug(PDBGF_PATH, "%s + %s => <%s>\n",