File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -32,13 +32,17 @@ void initialize_banman()
32
32
33
33
FUZZ_TARGET_INIT (banman, initialize_banman)
34
34
{
35
+ // The complexity is O(N^2), where N is the input size, because each call
36
+ // might call DumpBanlist (or other methods that are at least linear
37
+ // complexity of the input size).
38
+ int limit_max_ops{300 };
35
39
FuzzedDataProvider fuzzed_data_provider{buffer.data (), buffer.size ()};
36
40
SetMockTime (ConsumeTime (fuzzed_data_provider));
37
41
const fs::path banlist_file = GetDataDir () / " fuzzed_banlist.dat" ;
38
42
fs::remove (banlist_file);
39
43
{
40
44
BanMan ban_man{banlist_file, nullptr , ConsumeBanTimeOffset (fuzzed_data_provider)};
41
- while (fuzzed_data_provider.ConsumeBool ()) {
45
+ while (--limit_max_ops >= 0 && fuzzed_data_provider.ConsumeBool ()) {
42
46
CallOneOf (
43
47
fuzzed_data_provider,
44
48
[&] {
@@ -52,7 +56,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
52
56
[&] {
53
57
ban_man.ClearBanned ();
54
58
},
55
- [] {},
56
59
[&] {
57
60
ban_man.IsBanned (ConsumeNetAddr (fuzzed_data_provider));
58
61
},
@@ -72,7 +75,6 @@ FUZZ_TARGET_INIT(banman, initialize_banman)
72
75
[&] {
73
76
ban_man.DumpBanlist ();
74
77
},
75
- [] {},
76
78
[&] {
77
79
ban_man.Discourage (ConsumeNetAddr (fuzzed_data_provider));
78
80
});
You can’t perform that action at this time.
0 commit comments