Closed srenatus closed 7 years ago
Hey there.
I've taken the fuzzed input data I had lying around and fed it into jsone_decode:decode/1:
jsone_decode:decode/1
-module(jsone_decode_fuzz_tests). -include_lib("eunit/include/eunit.hrl"). radamsa_test_() -> FuzzedSamples = read_fuzzed_samples(), [{timeout, 300, input(Input)} || Input <- FuzzedSamples]. input(Input) -> {Input, fun() -> {ok, Bin} = file:read_file(Input), case jsone_decode:decode(Bin) of {ok, _, _} -> ok; {error, _} -> ok; Wat -> ?assertEqual(unlikely, Wat) end end}. read_fuzzed_samples() -> CasesPath = "/tmp/fuzzed/*", %% out of that dir so rebar won't copy it lists:sort(filelib:wildcard(CasesPath)).
After these fixes, it would always return {ok, _, _} or {error, _}, and never throw an exception.
{ok, _, _}
{error, _}
LGTM. Thanks for this improvement!
Hey there.
I've taken the fuzzed input data I had lying around and fed it into
jsone_decode:decode/1
:After these fixes, it would always return
{ok, _, _}
or{error, _}
, and never throw an exception.