@@ -2,6 +2,7 @@ use std::borrow::Cow;
22
33use bstr:: { BStr , ByteSlice } ;
44use gix_config:: File ;
5+ use gix_testtools:: fixture_path_standalone;
56
67pub fn cow_str ( s : & str ) -> Cow < ' _ , BStr > {
78 Cow :: Borrowed ( s. as_bytes ( ) . as_bstr ( ) )
@@ -27,7 +28,7 @@ mod open {
2728}
2829
2930#[ test]
30- fn fuzzed ( ) {
31+ fn fuzzed_stackoverflow ( ) {
3132 let file = File :: from_bytes_no_includes (
3233 include_bytes ! ( "../fixtures/fuzzed/stackoverflow-01.config" ) ,
3334 gix_config:: file:: Metadata :: default ( ) ,
@@ -43,6 +44,27 @@ fn fuzzed() {
4344 }
4445}
4546
47+ #[ test]
48+ fn fuzzed_long_runtime ( ) -> crate :: Result {
49+ let config = std:: fs:: read ( fixture_path_standalone ( "fuzzed/long-parsetime.config" ) ) ?;
50+ let file = File :: from_bytes_no_includes ( & config, gix_config:: file:: Metadata :: default ( ) , Default :: default ( ) ) ?;
51+ assert_eq ! ( file. sections( ) . count( ) , 52 ) ;
52+ assert_eq ! ( file. to_bstring( ) . len( ) , 180351853 ) ;
53+ File :: from_bytes_no_includes (
54+ & file. to_bstring ( ) ,
55+ gix_config:: file:: Metadata :: default ( ) ,
56+ Default :: default ( ) ,
57+ ) ?;
58+
59+ let mut mutated_file = file. clone ( ) ;
60+ mutated_file. append ( file) ;
61+ assert_eq ! ( mutated_file. sections( ) . count( ) , 52 * 2 ) ;
62+ let serialized = mutated_file. to_bstring ( ) ;
63+ assert_eq ! ( serialized. len( ) , 360703706 ) ;
64+ File :: from_bytes_no_includes ( & serialized, gix_config:: file:: Metadata :: default ( ) , Default :: default ( ) ) ?;
65+ Ok ( ( ) )
66+ }
67+
4668mod access;
4769mod impls;
4870mod init;
0 commit comments