File tree 4 files changed +34
-2
lines changed 4 files changed +34
-2
lines changed Original file line number Diff line number Diff line change
1
+ //! BSON Document Length Field Fuzzer
2
+ //!
3
+ //! This fuzz test focuses on finding security vulnerabilities related to BSON document length
4
+ //! fields. It specifically targets:
5
+ //! - Integer overflow/underflow in length calculations
6
+ //! - Malformed length fields that could cause buffer overruns
7
+ //! - Mismatches between declared and actual document sizes
8
+ //! - Memory allocation issues with large or invalid lengths
9
+
1
10
#![ no_main]
2
- #[ macro_use] extern crate libfuzzer_sys;
11
+ #[ macro_use]
12
+ extern crate libfuzzer_sys;
3
13
extern crate bson;
4
14
use bson:: RawDocument ;
5
15
Original file line number Diff line number Diff line change
1
+ //! Document serialization consistency
1
2
#![ no_main]
2
3
#[ macro_use]
3
4
extern crate libfuzzer_sys;
@@ -48,6 +49,25 @@ fuzz_target!(|buf: &[u8]| {
48
49
}
49
50
}
50
51
}
51
- let _ = doc_buf. into_bytes( ) ;
52
+ let output_bytes = doc_buf. into_bytes( ) ;
53
+ if let Ok ( reserialized_doc) = RawDocument :: from_bytes( & output_bytes) {
54
+ assert_eq!( doc. as_bytes( ) . len( ) , reserialized_doc. as_bytes( ) . len( ) ) ;
55
+ let orig_elements: Vec <_> = doc. iter_elements( ) . flatten( ) . collect( ) ;
56
+ let reser_elements: Vec <_> = reserialized_doc. iter_elements( ) . flatten( ) . collect( ) ;
57
+ assert_eq!(
58
+ orig_elements. len( ) ,
59
+ reser_elements. len( ) ,
60
+ "Document element count mismatch"
61
+ ) ;
62
+ for ( orig, reser) in orig_elements. iter( ) . zip( reser_elements. iter( ) ) {
63
+ assert_eq!( orig. key( ) , reser. key( ) , "Key mismatch" ) ;
64
+ assert_eq!(
65
+ orig. value( ) ,
66
+ reser. value( ) ,
67
+ "Value mismatch for key {}" ,
68
+ orig. key( )
69
+ ) ;
70
+ }
71
+ }
52
72
}
53
73
} ) ;
Original file line number Diff line number Diff line change
1
+ //! Ensure correctness of UTF-8 and string parsing
1
2
#![ no_main]
2
3
#[ macro_use]
3
4
extern crate libfuzzer_sys;
Original file line number Diff line number Diff line change
1
+ //! BSON type marker validation
1
2
#![ no_main]
2
3
#[ macro_use]
3
4
extern crate libfuzzer_sys;
You can’t perform that action at this time.
0 commit comments