You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let chunk_length = u32::from_be_bytes(buf_chunk_length)asusize;
657
+
let bytes_left = cursor_content.len() - (cursor.position()asusize);
658
+
if chunk_length > bytes_left {
659
+
// do NOT try to allocate massive buffer for `chunk_data` but instead fail early
660
+
returnErr(ReadError::Malformed(format!("Java-specific Snappy-compressed data has illegal chunk length, got {chunk_length} bytes but only {bytes_left} bytes are left.").into()));
661
+
}
656
662
657
663
letmut chunk_data = vec![0u8; chunk_length];
658
664
cursor.read_exact(&mut chunk_data)?;
@@ -1312,6 +1318,26 @@ mod tests {
1312
1318
assert_eq!(actual2, expected);
1313
1319
}
1314
1320
1321
+
#[test]
1322
+
fntest_decode_java_specific_oom(){
1323
+
// Found by the fuzzer, this should return an error instead of OOM.
let err = RecordBatchBody::read(&mutCursor::new(data)).unwrap_err();
1337
+
assert_matches!(err,ReadError::Malformed(_));
1338
+
assert_eq!(err.to_string(),"Malformed data: Java-specific Snappy-compressed data has illegal chunk length, got 4227860745 bytes but only 38 bytes are left.");
1339
+
}
1340
+
1315
1341
#[test]
1316
1342
fntest_carefully_decompress_snappy_empty_input(){
1317
1343
let err = carefully_decompress_snappy(&[],1).unwrap_err();
0 commit comments