Only allow absolute paths

This commit is contained in:
2025-11-06 21:58:24 +01:00
parent f3fcc92991
commit 2fa77d073f
6 changed files with 91 additions and 0 deletions

View File

@ -38,6 +38,19 @@ void path_parse(const char *in, char *mp, char *path) {
} else {
path[j] = 0;
}
if (path[0] != '/') {
mp[0] = 0;
path[0] = 0;
return;
}
if (string_strstr(path, "/../") || string_strstr(path, "/./")
|| string_strcmp(path, "..") == 0 || string_strcmp(path, ".") == 0) {
mp[0] = 0;
path[0] = 0;
return;
}
}
const char *path_basename(const char *path) {