The isofile_gen_utility_names function normalizes directories, including
dot dot directory entries. If such an entry has multiple slahes and leads
to the top directory, then the new path erroneously becomes absolute.
Skip multiple slashes.
If rp is not NULL, then it points to a slash already. Takes this into
account to unify the rp and dirname cases a bit more.
Resolves #2937.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* --> 'dir/dir2/'
*/
char *rp = p -1;
+ size_t off;
+ for (off = 4; p[off] == '/'; off++)
+ ;
while (rp >= dirname) {
if (*rp == '/')
break;
--rp;
}
if (rp > dirname) {
- memmove(rp, p + 3, strlen(p + 3) + 1);
+ memmove(rp + 1, p + off, strlen(p + off) + 1);
p = rp;
} else {
- memmove(dirname, p + 4, strlen(p + 4) + 1);
+ memmove(dirname, p + off, strlen(p + off) + 1);
p = dirname;
}
} else