Skip to content

Panic in do_parse with take #481

@chifflier

Description

@chifflier

Hi,

The following parser:

named!(parser02<&[u8],()>,
    do_parse!(
        hdr: take!(1) >>
        data: take!(18446744073709551615) >>
        ( () )
    )
);

#[test]
fn test02() {
    let data = b"0\x88\xff\xff\xff\xff\xff\xff\xff\xff00\x0f\x02\x000\x00\x00\x00\x00\x00\x0000\x0f\x00\xff\x0a\xbb\xff";
    let _ = parser02(data);
}

fails with an error:

thread 'test02' panicked at 'attempt to add with overflow', <do_parse macros>:33

The backtrace is not interesting, so not reported here.

The bug was originally discovered in rusticata/x509-parser#1

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