Skip to content

Commit

Permalink
Add tests for RUST-713
Browse files Browse the repository at this point in the history
  • Loading branch information
gperinazzo committed Mar 23, 2021
1 parent 4b7c046 commit e899afc
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/tests/modules/serializer_deserializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,3 +540,25 @@ fn test_serialize_deserialize_document() {
let bad_point: Result<Point, crate::de::Error> = from_document(bad_point);
assert!(bad_point.is_err());
}

/// [RUST-713](https://jira.mongodb.org/browse/RUST-713)
#[test]
fn test_deserialize_invalid_array_length() {
let _guard = LOCK.run_concurrently();
let buffer = b"\n\x00\x00\x00\x04\x00\x00\x00\x00\x00";
Document::from_reader(&mut std::io::Cursor::new(buffer))
.expect_err("expected deserialization to fail") ;
}

/// [RUST-713](https://jira.mongodb.org/browse/RUST-713)
#[test]
fn test_deserialize_invalid_old_binary_length() {
let _guard = LOCK.run_concurrently();
let buffer = b"\x0F\x00\x00\x00\x05\x00\x00\x00\x00\x00\x02\xFC\xFF\xFF\xFF";
Document::from_reader(&mut std::io::Cursor::new(buffer))
.expect_err("expected deserialization to fail") ;

let buffer = b".\x00\x00\x00\x05\x01\x00\x00\x00\x00\x00\x02\xfc\xff\xff\xff\xff\xff\xff\xff\x00\x00*\x00h\x0e\x10++\x00h\x0e++\x00\x00\t\x00\x00\x00\x00\x00*\x0e\x10++";
Document::from_reader(&mut std::io::Cursor::new(buffer))
.expect_err("expected deserialization to fail") ;
}

0 comments on commit e899afc

Please sign in to comment.