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

@ -1,4 +1,5 @@
#include "path.h"
#include "hal/hal.h"
void path_parse(const char *in, char *mp, char *path) {
if (in == 0 || *in == 0) {
@ -37,5 +38,18 @@ 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 (hal_strstr(path, "/../") || hal_strstr(path, "/./")
|| hal_strcmp(path, "..") == 0 || hal_strcmp(path, ".") == 0) {
mp[0] = 0;
path[0] = 0;
return;
}
}