stream_file: allow to open only our fd in case of fuzzing

This ensures that we don't open some other fd, for example when loading
playlist. Also filters out loading any local files.

This also allows to remove custom filtering from fuzzer itself.
This commit is contained in:
Kacper Michajłow
2025-01-28 06:41:44 +01:00
parent 9661a3839b
commit 1d352f8527
4 changed files with 13 additions and 37 deletions

View File

@@ -1182,18 +1182,6 @@ static void start_open(struct MPContext *mpctx, char *url, int url_flags,
mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
mpctx->demuxer_changed = false;
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
// Don't allow to open local paths or stdin during fuzzing
bstr open_url = bstr0(mpctx->open_url);
if (bstr_startswith0(open_url, "/") ||
bstr_startswith0(open_url, ".") ||
bstr_equals0(open_url, "-"))
{
cancel_open(mpctx);
return;
}
#endif
if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
cancel_open(mpctx);
return;