aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-10-09 15:35:34 +0200
committerEric Wong <normalperson@yhbt.net>2008-10-11 19:21:49 -0700
commit259f0fd80c9cf9eb06656dabcc6386a729d60127 (patch)
tree8cc46a41800ab8e3ac8e71c3c5526e7b8e488b1d /src
parent4a13e19cebb8d72db6e2db9ffb9f9dbd7194ede9 (diff)
downloadmpd-259f0fd80c9cf9eb06656dabcc6386a729d60127.tar.gz
mpd-259f0fd80c9cf9eb06656dabcc6386a729d60127.tar.xz
mpd-259f0fd80c9cf9eb06656dabcc6386a729d60127.zip
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.
Diffstat (limited to '')
-rw-r--r--src/directory_save.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/directory_save.c b/src/directory_save.c
index 27f7b14ce..cd79e178b 100644
--- a/src/directory_save.c
+++ b/src/directory_save.c
@@ -101,6 +101,10 @@ void 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 {