summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-07-18 12:52:59 +0200
committerwm4 <wm4@nowhere>2016-07-18 12:52:59 +0200
commit510c6a1be45fafa04a9136039bee9301078e0c20 (patch)
treec5e941cd90adf40cc68b527a0bab718253419296 /stream
parentfb8deb69a6afc311deb2c3f9bfa13e460e03256f (diff)
downloadmpv-510c6a1be45fafa04a9136039bee9301078e0c20.tar.bz2
mpv-510c6a1be45fafa04a9136039bee9301078e0c20.tar.xz
libarchive: sanitize non-UTF8 archive entries
Some client API users simply don't like such filenames. For their sake, don't return them, but return a dummy filename instead. (Returning a latin1-ized version would work too, but is slightly more work.) Also remove the "\n" from the replacement dummy filename. This was accidental.
Diffstat (limited to 'stream')
-rw-r--r--stream/stream_libarchive.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/stream/stream_libarchive.c b/stream/stream_libarchive.c
index 9d93af5450..50177028ea 100644
--- a/stream/stream_libarchive.c
+++ b/stream/stream_libarchive.c
@@ -290,8 +290,8 @@ bool mp_archive_next_entry(struct mp_archive *mpa)
// Some archives may have no filenames, or libarchive won't return some.
const char *fn = archive_entry_pathname(entry);
char buf[64];
- if (!fn) {
- snprintf(buf, sizeof(buf), "mpv_unknown#%d\n", mpa->entry_num);
+ if (!fn || bstr_validate_utf8(bstr0(fn)) < 0) {
+ snprintf(buf, sizeof(buf), "mpv_unknown#%d", mpa->entry_num);
fn = buf;
}
mpa->entry = entry;