Skip to content

Attempt to subtract with overflow erros #78

Description

@forzafedor

Hi!
We're fuzzing a project that uses your library and found this bugs:

subtract-1.txt

#[test]
fn test1() {
    use rxing::DecodeHints;
    let mut hints: DecodeHints =
        DecodeHints::default().with(rxing::DecodeHintValue::TryHarder(true));

    let mut data = Vec::new();
    std::fs::File::open("subtract-1.txt")
        .unwrap()
        .read_to_end(&mut data)
        .unwrap();
    rxing::helpers::detect_multiple_in_luma_with_hints(data, 682, 504, &mut hints).unwrap_or_default();

backtrace:

thread 'subtract_with_overflow' (8655) panicked at src/qrcode/detector/qrcode_detector.rs:432:13:
attempt to subtract with overflow

subtract-2.txt

#[test]
fn test2() {
    use rxing::DecodeHints;
    let mut hints: DecodeHints =
        DecodeHints::default().with(rxing::DecodeHintValue::TryHarder(true));

    let mut data = Vec::new();
    std::fs::File::open("subtract-2.txt")
        .unwrap()
        .read_to_end(&mut data)
        .unwrap();
    rxing::helpers::detect_multiple_in_luma_with_hints(data, 678, 504, &mut hints).unwrap_or_default();

backtrace:

thread 'subtract_with_overflow' (8977) panicked at src/qrcode/detector/qrcode_detector.rs:438:12:
attempt to subtract with overflow

subtract-3.txt

#[test]
fn test3() {
    use rxing::DecodeHints;
    let mut hints: DecodeHints =
        DecodeHints::default().with(rxing::DecodeHintValue::TryHarder(true));

    let mut data = Vec::new();
    std::fs::File::open("subtract-3.txt")
        .unwrap()
        .read_to_end(&mut data)
        .unwrap();
    rxing::helpers::detect_multiple_in_luma_with_hints(data, 672, 504, &mut hints).unwrap_or_default();

backtrace:

thread 'subtract_with_overflow' (9122) panicked at src/qrcode/decoder/version.rs:155:35:
attempt to subtract with overflow

It seems the errors are not very serious, I will send the PR to fix them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions