@@ -2,6 +2,7 @@ use std::borrow::Cow;
2
2
3
3
use bstr:: { BStr , ByteSlice } ;
4
4
use gix_config:: File ;
5
+ use gix_testtools:: fixture_path_standalone;
5
6
6
7
pub fn cow_str ( s : & str ) -> Cow < ' _ , BStr > {
7
8
Cow :: Borrowed ( s. as_bytes ( ) . as_bstr ( ) )
@@ -27,7 +28,7 @@ mod open {
27
28
}
28
29
29
30
#[ test]
30
- fn fuzzed ( ) {
31
+ fn fuzzed_stackoverflow ( ) {
31
32
let file = File :: from_bytes_no_includes (
32
33
include_bytes ! ( "../fixtures/fuzzed/stackoverflow-01.config" ) ,
33
34
gix_config:: file:: Metadata :: default ( ) ,
@@ -43,6 +44,27 @@ fn fuzzed() {
43
44
}
44
45
}
45
46
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
+
46
68
mod access;
47
69
mod impls;
48
70
mod init;
0 commit comments