-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fuzz: add decode_aac, fix compilation errors and simplify code
- Loading branch information
Showing
4 changed files
with
46 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use symphonia::core::codecs::audio::{AudioCodecParameters, AudioDecoder}; | ||
use symphonia::core::codecs::audio::well_known::CODEC_ID_AAC; | ||
use symphonia::core::formats::Packet; | ||
use symphonia::default::codecs::AacDecoder; | ||
|
||
fuzz_target!(|data: Vec<u8>| { | ||
let mut codec_params = AudioCodecParameters::new(); | ||
codec_params.for_codec(CODEC_ID_AAC); | ||
|
||
if let Ok(mut decoder) = AacDecoder::try_new(&codec_params, &Default::default()) { | ||
let packet = Packet::new_from_boxed_slice(0, 0, 0, data.into_boxed_slice()); | ||
decoder.decode(&packet).ok(); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,32 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use symphonia::core::codecs::DecoderOptions; | ||
use symphonia::core::codecs::audio::AudioDecoderOptions; | ||
use symphonia::core::formats::FormatOptions; | ||
use symphonia::core::formats::probe::Hint; | ||
use symphonia::core::formats::TrackType; | ||
use symphonia::core::meta::MetadataOptions; | ||
use symphonia::core::probe::Hint; | ||
|
||
fuzz_target!(|data: Vec<u8>| { | ||
let data = std::io::Cursor::new(data); | ||
|
||
let source = symphonia::core::io::MediaSourceStream::new(Box::new(data), Default::default()); | ||
|
||
match symphonia::default::get_probe().format( | ||
if let Ok(mut format) = symphonia::default::get_probe().probe( | ||
&Hint::new(), | ||
source, | ||
&FormatOptions::default(), | ||
&MetadataOptions::default(), | ||
FormatOptions::default(), | ||
MetadataOptions::default(), | ||
) { | ||
Ok(mut probed) => { | ||
let track = probed.format.default_track().unwrap(); | ||
|
||
let mut decoder = match symphonia::default::get_codecs() | ||
.make(&track.codec_params, &DecoderOptions::default()) | ||
{ | ||
Ok(d) => d, | ||
Err(_) => return, | ||
}; | ||
|
||
loop { | ||
let packet = match probed.format.next_packet() { | ||
Ok(p) => p, | ||
Err(_) => return, | ||
}; | ||
let _ = decoder.decode(&packet); | ||
if let Some(track) = format.default_track(TrackType::Audio) { | ||
if let Some(codec_params) = track.codec_params.as_ref() { | ||
if let Ok(mut decoder) = symphonia::default::get_codecs().make_audio_decoder( | ||
&codec_params.audio().unwrap(), | ||
&AudioDecoderOptions::default(), | ||
) { | ||
while let Ok(Some(packet)) = format.next_packet() { | ||
let _ = decoder.decode(&packet); | ||
} | ||
} | ||
} | ||
} | ||
Err(_) => {} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
#![no_main] | ||
use libfuzzer_sys::fuzz_target; | ||
use symphonia::core::codecs::{CODEC_ID_MP3, CodecParameters, Decoder}; | ||
use symphonia::core::codecs::audio::{AudioCodecParameters, AudioDecoder}; | ||
use symphonia::core::codecs::audio::well_known::CODEC_ID_MP3; | ||
use symphonia::core::formats::Packet; | ||
use symphonia::default::codecs::MpaDecoder; | ||
|
||
fuzz_target!(|data: Vec<u8>| { | ||
let mut codec_params = CodecParameters::new(); | ||
let mut codec_params = AudioCodecParameters::new(); | ||
codec_params.for_codec(CODEC_ID_MP3); | ||
|
||
let mut decoder = MpaDecoder::try_new(&codec_params, &Default::default()).unwrap(); | ||
|
||
let packet = Packet::new_from_boxed_slice(0, 0, 0, data.into_boxed_slice()); | ||
let _ = decoder.decode(&packet); | ||
if let Ok(mut decoder) = MpaDecoder::try_new(&codec_params, &Default::default()) { | ||
let packet = Packet::new_from_boxed_slice(0, 0, 0, data.into_boxed_slice()); | ||
decoder.decode(&packet).ok(); | ||
} | ||
}); |