pdeljanov / Symphonia

Pure Rust multimedia format demuxing, tag reading, and audio decoding library
Mozilla Public License 2.0
2.42k stars 144 forks source link

Attempt to add with overflow when checking m4a file #300

Open qarmin opened 4 months ago

qarmin commented 4 months ago

Code

pub fn parse_audio_file(file_handler: File) -> Result<(), Error> {
    let mss = MediaSourceStream::new(Box::new(file_handler), Default::default());

    let probed = match symphonia::default::get_probe().format(
        &Default::default(),
        mss,
        &Default::default(),
        &Default::default(),
    ) {
        Ok(t) => t,
        Err(_) => {
            return Err(Error::Unsupported(
                "probe info not available/file not recognized",
            ))
        }
    };

    let mut format = probed.format;

    let track = match format
        .tracks()
        .iter()
        .find(|t| t.codec_params.codec != CODEC_TYPE_NULL)
    {
        Some(k) => k,
        None => return Err(Error::Unsupported("not supported audio track")),
    };

    let mut decoder =
        match symphonia::default::get_codecs().make(&track.codec_params, &Default::default()) {
            Ok(k) => k,
            Err(_) => return Err(Error::Unsupported("not supported codec")),
        };

    loop {
        let packet = match format.next_packet() {
            Ok(packet) => packet,
            Err(Error::ResetRequired) => {
                return Err(Error::ResetRequired);
            }
            Err(err) => {
                if let IoError(ref er) = err {
                    // Catch eof, not sure how to do it properly
                    if er.kind() == io::ErrorKind::UnexpectedEof {
                        return Ok(());
                    }
                }
                return Err(err);
            }
        };

        decoder.decode(&packet)?;
    }
}
thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/stts.rs:97:13:
attempt to add with overflow
stack backtrace:
   0: rust_begin_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
   1: core::panicking::panic_fmt
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
   2: core::panicking::panic_const::panic_const_add_overflow
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:180:21
   3: <symphonia_format_isomp4::atoms::stts::SttsAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/stts.rs:97:13
   4: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
   5: <symphonia_format_isomp4::atoms::stbl::StblAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/stbl.rs:50:33
   6: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
   7: <symphonia_format_isomp4::atoms::minf::MinfAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/minf.rs:41:33
   8: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
   9: <symphonia_format_isomp4::atoms::mdia::MdiaAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mdia.rs:42:33
  10: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
  11: <symphonia_format_isomp4::atoms::trak::TrakAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/trak.rs:47:33
  12: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
  13: <symphonia_format_isomp4::atoms::moov::MoovAtom as symphonia_format_isomp4::atoms::Atom>::read
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/moov.rs:64:32
  14: symphonia_format_isomp4::atoms::AtomIterator<B>::read_atom
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/atoms/mod.rs:470:9
  15: <symphonia_format_isomp4::demuxer::IsoMp4Reader as symphonia_core::formats::FormatReader>::try_new
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-format-isomp4-0.5.4/src/demuxer.rs:359:33
  16: <symphonia_format_isomp4::demuxer::IsoMp4Reader as symphonia_core::probe::QueryDescriptor>::query::{{closure}}
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-core-0.5.4/src/probe.rs:360:65
  17: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
  18: symphonia_core::probe::Probe::format
             at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/symphonia-core-0.5.4/src/probe.rs:326:34
  19: symphonia::parse_audio_file
             at ./src/crates/symphonia/src/main.rs:43:24
  20: symphonia::check_file
             at ./src/crates/symphonia/src/main.rs:37:13
  21: symphonia::main
             at ./src/crates/symphonia/src/main.rs:24:9
  22: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
timeout: the monitored command dumped core

##### Automatic Fuzzer note, output status "None", output signal "Some(6)"

compressed.zip