Skip to content

avro: VLQDecoder::long doesn't protect against invalid input #10290

Description

@Jefffrey

Describe the bug

/// Decode a signed long from `buf`
pub fn long(&mut self, buf: &mut &[u8]) -> Option<i64> {
while let Some(byte) = buf.first().copied() {
*buf = &buf[1..];
self.in_progress |= ((byte & 0x7F) as u64) << self.shift;
self.shift += 7;
if byte & 0x80 == 0 {
let val = self.in_progress;
self.in_progress = 0;
self.shift = 0;
return Some((val >> 1) as i64 ^ -((val & 1) as i64));
}
}
None
}

malformed/malicious input could cause this loop to run more than expected for a valid input and cause panic/overflow

see related PR:

To Reproduce

No response

Expected behavior

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions