diff --git a/fuzz/dfuzz.cc b/fuzz/dfuzz.cc index c926d61..29e6b57 100644 --- a/fuzz/dfuzz.cc +++ b/fuzz/dfuzz.cc @@ -23,20 +23,21 @@ using namespace lc3; extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - const int dt_list[] = { 7500, 10000 }; - const int sr_list[] = { 8000, 16000, 24000, 32000, 48000 }; + const int dt_list[] = { 2500, 5000, 7500, 10000 }; + const int sr_list[] = { 8000, 16000, 24000, 32000, 48000, 96000 }; FuzzedDataProvider fdp(data, size); int dt_us = fdp.PickValueInArray(dt_list); int sr_hz = fdp.PickValueInArray(sr_list); int nchannels =fdp.PickValueInArray({1, 2}); + bool hrmode = fdp.ConsumeBool(); int sr_pcm_hz = fdp.PickValueInArray(sr_list); if (sr_pcm_hz < sr_hz) sr_pcm_hz = 0; - Decoder dec(dt_us, sr_hz, sr_pcm_hz, nchannels); + Decoder dec(dt_us, sr_hz, sr_pcm_hz, nchannels, hrmode); int frame_size = fdp.ConsumeIntegralInRange( LC3_MIN_FRAME_BYTES, LC3_MAX_FRAME_BYTES); @@ -46,6 +47,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) PcmFormat::kS24In3Le, PcmFormat::kF32 }); int frame_samples = dec.GetFrameSamples(); + if (frame_samples < 0) + return -1; int sample_bytes = fmt == PcmFormat::kS16 ? sizeof(int16_t) : diff --git a/fuzz/efuzz.cc b/fuzz/efuzz.cc index e79ef9c..be68b9c 100644 --- a/fuzz/efuzz.cc +++ b/fuzz/efuzz.cc @@ -70,7 +70,7 @@ int encode(Encoder &e, int frame_size, int nchannels, extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - const int dt_list[] = { 7500, 10000 }; + const int dt_list[] = { 2500, 5000, 7500, 10000 }; const int sr_list[] = { 8000, 16000, 24000, 32000, 48000 }; FuzzedDataProvider fdp(data, size); @@ -78,12 +78,13 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) int dt_us = fdp.PickValueInArray(dt_list); int sr_hz = fdp.PickValueInArray(sr_list); int nchannels = fdp.PickValueInArray({1, 2}); + bool hrmode = fdp.ConsumeBool(); int sr_pcm_hz = fdp.PickValueInArray(sr_list); if (sr_pcm_hz < sr_hz) sr_pcm_hz = 0; - Encoder enc(dt_us, sr_hz, sr_pcm_hz, nchannels); + Encoder enc(dt_us, sr_hz, sr_pcm_hz, nchannels, hrmode); PcmFormat fmt = fdp.PickValueInArray( { PcmFormat::kS16, PcmFormat::kS24,