History

player/loadfile: prevent fuzzers from loading absolute directories

It's waste of time to load external files. And it is not deterministic. Note we still allow to load single files by name, but it is not a big deal.

Kacper Michajłow committed 2 years ago

Commit b13642e1 parent aea5b3d1 file · +12 −0Browse files

Unified · Split

player/loadfile.c+12−0
@@ -1212,6 +1212,18 @@ static void start_open(struct MPContext *mpctx, char *url, int url_flags, · 1211 unmodified lines
12121212 mpctx->open_url_flags = url_flags;
12131213 mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread;
12141214
1215+#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
1216+ // Don't allow to open local paths or stdin during fuzzing
1217+ bstr open_url = bstr0(mpctx->open_url);
1218+ if (bstr_startswith0(open_url, "/") ||
1219+ bstr_startswith0(open_url, "./") ||
1220+ bstr_equals0(open_url, "-"))
1221+ {
1222+ cancel_open(mpctx);
1223+ return;
1224+ }
1225+#endif
1226+
12151227 if (mp_thread_create(&mpctx->open_thread, open_demux_thread, mpctx)) {
12161228 cancel_open(mpctx);
12171229 return;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t