Skip to content

Decoding does not detect overflowing correctly and returns a number #73

@oblique

Description

@oblique

Decoding does not detect overflowing correctly and returns a number. This can accept malformed data and cause misbehaviours.

Reproduction:

fn main() {
    let number = u64::MAX as u128 + 10000;

    let mut buf = unsigned_varint::encode::u128_buffer();
    let bytes = unsigned_varint::encode::u128(number, &mut buf);

    println!("input number: {number}");
    println!("input bytes: {bytes:02x?}");

    let (output, _rest) = unsigned_varint::decode::u64(&bytes).unwrap();
    println!("output number: {output:?}");
}
input number: 18446744073709561615
input bytes: [8f, ce, 80, 80, 80, 80, 80, 80, 80, 02]
output number: 9999

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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