Only allow absolute paths
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user