diff options
author | Max Kellermann <max@duempel.org> | 2008-10-09 15:35:34 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-10-09 15:35:34 +0200 |
commit | 702739b879e1515fad571df0590be3e3f1e22cae (patch) | |
tree | b5443db967d2506557e91600ee00a9624a25ea56 /src | |
parent | cbc076461371fca57749191fb323cf75b43d9544 (diff) | |
download | mpd-702739b879e1515fad571df0590be3e3f1e22cae.tar.gz mpd-702739b879e1515fad571df0590be3e3f1e22cae.tar.xz mpd-702739b879e1515fad571df0590be3e3f1e22cae.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 'src')
-rw-r--r-- | src/directory_save.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/directory_save.c b/src/directory_save.c index 36b0c1a01..00cf5f8e0 100644 --- a/src/directory_save.c +++ b/src/directory_save.c @@ -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 { |