Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pack of broken files #301

Open
qarmin opened this issue Jul 11, 2024 · 4 comments
Open

Pack of broken files #301

qarmin opened this issue Jul 11, 2024 · 4 comments

Comments

@qarmin
Copy link

qarmin commented Jul 11, 2024

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)?;
    }
}

Several crashes, different than previously reported(unwraps, panics etc.)

Untitled Folder.zip

@sscobici
Copy link

sscobici commented Dec 27, 2024

Hi @qarmin,

I created a pull request for 0.6 branch which should fix panics from your examples once it will be merged.
What scripts, software you used to generate those test m4a files?

@qarmin
Copy link
Author

qarmin commented Dec 27, 2024

I use cargo-fuzz with corpus and own program(create_broken_files) which randomly modify input files.

Both are used by https://github.com/qarmin/Automated-Fuzzer, which fuzz several programs in CI.

I already changed symphonia commit to #331, which seems to fix most(or even all) isomp4 issues

cargo-fuzz - https://github.com/qarmin/Automated-Fuzzer/actions/runs/12516279820 (results in "minimized..." files)
custom fuzzing - https://github.com/qarmin/Automated-Fuzzer/actions/runs/12516290494 (results in "REPORTS_SYMPHONIA...")

This CI runs once a day, so it won't be hard for me to report new files that cause problems

@sscobici
Copy link

Thanks @qarmin, that's a great work!!!

No need to submit new issues, I will take a look at other cases.
Keep this issue open for now, until all panics are resolved.

@qarmin
Copy link
Author

qarmin commented Jan 3, 2025

~20000 files from today CI run(symphonia version taken from #331)

A.7z.zip (this is 7z, but github not allows to publish files with such extension)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants