path: removed sanitizePathDup()
We don't need to sanitize the path, because the mapper already checks for malformed paths.
This commit is contained in:
40
src/path.c
40
src/path.c
@@ -168,43 +168,3 @@ char *pfx_dir(char *dst,
|
||||
/* this is weird, but directory.c can use it more safely/efficiently */
|
||||
return (dst + pfx_len + 1);
|
||||
}
|
||||
|
||||
char *sanitizePathDup(const char *path)
|
||||
{
|
||||
int len = strlen(path) + 1;
|
||||
char *ret = xmalloc(len);
|
||||
char *cp = ret;
|
||||
|
||||
memset(ret, 0, len);
|
||||
|
||||
len = 0;
|
||||
|
||||
/* eliminate more than one '/' in a row, like "///" */
|
||||
while (*path) {
|
||||
while (*path == '/')
|
||||
path++;
|
||||
if (*path == '.') {
|
||||
/* we don't want to have hidden directories, or '.' or
|
||||
".." in our path */
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
while (*path && *path != '/') {
|
||||
*(cp++) = *(path++);
|
||||
len++;
|
||||
}
|
||||
if (*path == '/') {
|
||||
*(cp++) = *(path++);
|
||||
len++;
|
||||
}
|
||||
}
|
||||
|
||||
if (len && ret[len - 1] == '/') {
|
||||
len--;
|
||||
ret[len] = '\0';
|
||||
}
|
||||
|
||||
DEBUG("sanitized: %s\n", ret);
|
||||
|
||||
return xrealloc(ret, len + 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user