Commit 0712314d authored by Max Kellermann's avatar Max Kellermann

archive/{zzip,iso9660}: ignore file names which are invalid UTF-8

These malformed strings must not be transferred over the wire, because the MPD protocol is defined to be UTF-8. Closes https://github.com/MusicPlayerDaemon/MPD/issues/1274
parent f8cbba18
...@@ -10,6 +10,8 @@ ver 0.23 (not yet released) ...@@ -10,6 +10,8 @@ ver 0.23 (not yet released)
- proxy: require libmpdclient 2.11 or later - proxy: require libmpdclient 2.11 or later
- proxy: split search into chunks to avoid exceeding the output buffer - proxy: split search into chunks to avoid exceeding the output buffer
- upnp: support libnpupnp instead of libupnp - upnp: support libnpupnp instead of libupnp
* archive
- zzip, iso9660: ignore file names which are invalid UTF-8
* decoder * decoder
- openmpt: new plugin - openmpt: new plugin
- wavpack: fix WVC file support - wavpack: fix WVC file support
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "util/UTF8.hxx"
#include "util/WritableBuffer.hxx" #include "util/WritableBuffer.hxx"
#include <cdio/iso9660.h> #include <cdio/iso9660.h>
...@@ -102,6 +103,10 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity, ...@@ -102,6 +103,10 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
/* skip special names like "." and ".." */ /* skip special names like "." and ".." */
continue; continue;
if (!ValidateUTF8(filename))
/* ignore file names which are not valid UTF-8 */
continue;
size_t filename_length = strlen(filename); size_t filename_length = strlen(filename);
if (length + filename_length + 1 >= capacity) if (length + filename_length + 1 >= capacity)
/* file name is too long */ /* file name is too long */
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "system/Error.hxx" #include "system/Error.hxx"
#include "util/RuntimeError.hxx" #include "util/RuntimeError.hxx"
#include "util/UTF8.hxx"
#include <zzip/zzip.h> #include <zzip/zzip.h>
...@@ -84,7 +85,7 @@ ZzipArchiveFile::Visit(ArchiveVisitor &visitor) ...@@ -84,7 +85,7 @@ ZzipArchiveFile::Visit(ArchiveVisitor &visitor)
ZZIP_DIRENT dirent; ZZIP_DIRENT dirent;
while (zzip_dir_read(dir->dir, &dirent)) while (zzip_dir_read(dir->dir, &dirent))
//add only files //add only files
if (dirent.st_size > 0) if (dirent.st_size > 0 && ValidateUTF8(dirent.d_name))
visitor.VisitArchiveEntry(dirent.d_name); visitor.VisitArchiveEntry(dirent.d_name);
} }
......
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