Permalink
Browse files

Fix canonicalization of paths ending with ".", like "/foo/." or "/foo…

…/./..".

This commit reverts cb1143a to provide a more generic fix.
  • Loading branch information...
cedric-vincent committed Mar 22, 2012
1 parent 8363061 commit c8f7312803c8d6562f1b22f0c90d731afb63937e
Showing with 28 additions and 18 deletions.
  1. +0 −11 doc/roadmap.txt
  2. +6 −1 src/path/canon.c
  3. +4 −6 src/path/path.c
  4. +18 −0 tests/test-cb1143ab.sh
View
@@ -5,17 +5,6 @@
Next minor
==========
-* Fix the termination of the canonicalized path in the following case:
-
- $ cd /foo/bar
- $ proot -v -b . [...]
- [...]
- proot info: binding = /foo/bar:/foo/bar/.
-
- $ proot -v -b .. [...]
- [...]
- proot info: binding = /foo
-
* Fix the detranslation of "conflicting" host-side bindings.
The detranslation isn't a state machine yet, hence it doesn't know
View
@@ -93,11 +93,16 @@ int canonicalize(pid_t pid, const char *fake_path, int deref_final,
return status;
is_final = status;
- if (strcmp(component, ".") == 0 && !is_final)
+ if (strcmp(component, ".") == 0) {
+ if (is_final)
+ is_final = FINAL_FORCE_DIR;
continue;
+ }
if (strcmp(component, "..") == 0) {
pop_component(result);
+ if (is_final)
+ is_final = FINAL_FORCE_DIR;
continue;
}
View
@@ -121,17 +121,15 @@ void pop_component(char *path)
}
/* Skip trailing path separators. */
- while (path[offset] == '/')
+ while (offset > 1 && path[offset] == '/')
offset--;
/* Search for the previous path separator. */
- while (path[offset] != '/')
+ while (offset > 1 && path[offset] != '/')
offset--;
- /* Cut the end of the string before the last component. Note
- * that the last path separator is kept (root or directory
- * sign). */
- path[offset+1] = '\0';
+ /* Cut the end of the string before the last component. */
+ path[offset] = '\0';
assert(path[0] == '/');
}
View
@@ -0,0 +1,18 @@
+if [ -z `which mcookie` ] || [ -z `which mkdir` ] || [ -z `which ln` ] || [ -z `which ls` ]; then
+ exit 125;
+fi
+
+D1=`mcookie`
+D2=`mcookie`
+TMP=/tmp/${D1}/${D2}
+
+mkdir -p ${TMP}
+ln -s ${TMP}/./. ${TMP}/link
+
+${PROOT} / \ls ${TMP}/link | grep ^link$
+${PROOT} / \ls ${TMP}/link/ | grep ^link$
+${PROOT} / \ls ${TMP}/link/. | grep ^link$
+${PROOT} / \ls ${TMP}/link/.. | grep ^${D2}$
+${PROOT} / \ls ${TMP}/link/./.. | grep ^${D2}$
+
+rm -fr /tmp/${D1}

0 comments on commit c8f7312

Please sign in to comment.