fuzzers: add new fuzzer targets

fuzzer_set_property.c:

fuzz mpv_set_property in both initialized and non-initialized state.
Useful for user provided values sanitization test. I've already seen
some memory leaks in parsing code, good to drill it.

fuzzer_loadfile.c:

mpv_command "loadfile" test. Good for testing demuxers, decoding and
playback loop. Sadly in headless mode we can't really test AO and VO,
but at least all the code around can be fuzzed. Especially our custom
demuxers like demux_mkv.

fuzzer_loadfile_direct.c:

Similar to loadfile above, but instead of saving the data to file, it
passes the fuzz input in the command. Generated protocol specific
versions (mf:// and memory:// for now) and generic one.

Nothing really complex, but good start and even those few targets should
give good coverage of the most common code paths in libmpv.
This commit is contained in:
Kacper Michajłow
2024-02-03 05:40:06 +01:00
parent 0b234af113
commit 47dbc3a74e
7 changed files with 319 additions and 0 deletions

View File

@@ -379,6 +379,15 @@ pthread_debug = get_option('pthread-debug').require(
)
features += {'pthread-debug': pthread_debug.allowed()}
if get_option('fuzzers')
if get_option('cplayer') or not get_option('libmpv')
error('fuzzers require !cplayer and libmpv')
endif
# Adding flags manually until https://github.com/mesonbuild/meson/pull/9825
flags += ['-fsanitize=address,undefined,fuzzer', '-fno-omit-frame-pointer']
link_flags += ['-fsanitize=address,undefined,fuzzer', '-fno-omit-frame-pointer']
endif
add_project_arguments(flags, language: 'c')
add_project_arguments(['-Wno-unused-parameter'], language: 'objc')
add_project_link_arguments(link_flags, language: ['c', 'objc'])
@@ -1803,6 +1812,10 @@ if get_option('tests')
subdir('test')
endif
if get_option('fuzzers')
subdir('fuzzers')
endif
summary({'d3d11': features['d3d11'],
'javascript': features['javascript'],
'libmpv': get_option('libmpv'),