Skip to content

Commit

Permalink
Fix panic on malformed input
Browse files Browse the repository at this point in the history
Fixes #27
  • Loading branch information
est31 committed Sep 7, 2018
1 parent 26a6c70 commit ddd2408
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1092,6 +1092,11 @@ pub fn read_audio_packet(ident :&IdentHeader, setup :&SetupHeader, packet :&[u8]
let prev = prev_chan[0..plen].into_iter();

let (lhs, rhs) = {
if win_slope.len() < plen {
// According to fuzzing, code can trigger this case,
// so let's error gracefully instead of panicing.
try!(Err(AudioReadError::AudioBadFormat));
}
let win_slope = &win_slope[0..plen];
(win_slope.iter(), win_slope.iter().rev())
};
Expand Down

0 comments on commit ddd2408

Please sign in to comment.