From 510c6a1be45fafa04a9136039bee9301078e0c20 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 18 Jul 2016 12:52:59 +0200 Subject: 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. --- stream/stream_libarchive.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream') 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; -- cgit v1.2.3