Commit ce299845 authored by Nils Goroll's avatar Nils Goroll

bugfix: With slashes near a multiples of PATH_MAX - 1 into the path,...

bugfix: With slashes near a multiples of PATH_MAX - 1 into the path, liblongpath could return results for a wrong path

skip all trailing slashes before starting the search, this is
required because otherwise the 'rest' path could start with a
slash (would work on wrong path) or be the empty string
(yield undefined error)
parent bf6ab281
......@@ -374,8 +374,18 @@ oatl_im(int filedes, const char *path, const char **remaining) {
assert(l == strlen(p));
/* find last slash for strlen(component) < PATH_MAX */
sl = p + PATH_MAX - 1;
/*
* skip all trailing slashes before starting the search, this is
* required because otherwise the 'rest' path could start with a
* slash (would work on wrong path) or be the empty string
* (yield undefined error)
*/
while ((sl > p) && (*sl == '/'))
sl--;
while (sl > p) {
if (*sl == '/')
goto found;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment