mapper: check for "." and ".."
Make map_directory_child_fs() refuse the names "." and "..". This is currently the interface where an attacker may inject a manipulated path (through the "update" command).
This commit is contained in:
parent
a5f8d4386c
commit
f291876772
|
@ -100,6 +100,11 @@ map_directory_child_fs(const struct directory *directory, const char *name,
|
||||||
char buffer2[MPD_PATH_MAX];
|
char buffer2[MPD_PATH_MAX];
|
||||||
const char *parent_fs;
|
const char *parent_fs;
|
||||||
|
|
||||||
|
/* check for invalid or unauthorized base names */
|
||||||
|
if (*name == 0 || strchr(name, '/') != NULL ||
|
||||||
|
strcmp(name, ".") == 0 || strcmp(name, "..") == 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
parent_fs = map_directory_fs(directory, buffer2);
|
parent_fs = map_directory_fs(directory, buffer2);
|
||||||
if (parent_fs == NULL)
|
if (parent_fs == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue