Browse Source

Fixed fl_wrapper symlink handling

Credits to the T2 project where I got this fix from.

Original log message (r20541):

* hardened the fl_wrapper to not segfault for unbalanced parent
  directory (..) references hitting the root (/) node
* fixed the fl_wrapper to also expand current (.) and parent (..)
  directory references whithout trailing slash and not leak trailing
  slashes
misl/sde-wrapper
Christian Wiese 17 years ago
parent
commit
3847c5f49e
1 changed files with 9 additions and 6 deletions
  1. +9
    -6
      src/tools-source/fl_wrapper.c.sh

+ 9
- 6
src/tools-source/fl_wrapper.c.sh

@ -419,21 +419,24 @@ static void sort_of_realpath (const char *file, char *absfile)
/* till the end, remove ./ and ../ parts */
while (dst < absfile + PATH_MAX && *src) {
if (*src == '.') {
if (src[1] == '.' && src[2] == '/') {
if (dst > file) --dst; /* jump to last '/' */
while (dst > file && dst[-1] != '/')
if (src[1] == '.' && (src[2] == '/' || src[2] == 0)) {
if (dst > absfile+1) --dst; /* jump to last '/' */
while (dst >absfile+1 && dst[-1] != '/')
--dst;
src += 3;
src += 2; if (*src) src++;
continue;
}
else if (src[1] == '/') {
src += 2;
else if (src[1] == '/' || src[1] == 0) {
src += 1; if (*src) src++;
continue;
}
}
*dst++ = *src++;
}
*dst = 0;
/* remove trailing slashes */
while (--dst, dst > absfile+1 && *dst == '/')
*dst = 0;
}
static void handle_file_access_after(const char * func, const char * file,

Loading…
Cancel
Save