Commit 702739b8 authored by Max Kellermann's avatar Max Kellermann

directory: check the absolute path of a subdirectory while loading

A manipulated database could trigger an assertion failure, because the parent didn't match. Do a proper check if the new directory is within the parent's. This uses FATAL() to bail out, so MPD still dies, but it doesn't crash.
parent cbc07646
......@@ -84,6 +84,10 @@ directory_load(FILE *fp, struct directory *directory)
if (prefixcmp(buffer, DIRECTORY_BEGIN))
FATAL("Error reading db at line: %s\n", buffer);
name = &(buffer[strlen(DIRECTORY_BEGIN)]);
if (prefixcmp(name, directory->path) != 0)
FATAL("Wrong path in database: '%s' in '%s'\n",
name, directory->path);
if ((subdir = db_get_directory(name))) {
assert(subdir->parent == directory);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment