Skip to content

index out of bounds panic when parsing bytes #11

Open

Description

@frewsxcv
extern crate flac;

use flac::{ByteStream, Stream};

fn main() {
    let s = Stream::<ByteStream>::from_buffer(b"fLaC\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00H\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xff\xff\\");
    if let Ok(mut stream) = s {
        let _ = stream.info();
        let _ = stream.metadata();
        let mut iter = stream.iter::<i8>();
        while iter.next().is_some() { }
    }
}
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /root/.cargo/git/checkouts/flac-34fb57da42139a77/9549bf8/src/utility/macros.rs:9

Found via https://github.com/rust-fuzz/cargo-fuzz

Activity

  1. j-n-f commented on Nov 9, 2025

    @j-n-f

    https://datatracker.ietf.org/doc/rfc9639/

    We have bytes fLaC followed by a header (big-endian): 0x01, 0x00, 0x00, 0x00. Per 8.1 this is a Padding (0x01) metadata block. Per sections 8 and 8.2 the first metadata block must be StreamInfo (i.e. first byte 0x00).

    With that said, this crate hasn't seen activity for nearly a decade. It may be better to try https://github.com/tuffy/flac-codec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions