Skip to content

Commit c476a04

Browse files
committed
created slow input example
1 parent ff5b23b commit c476a04

File tree

7 files changed

+61
-2
lines changed

7 files changed

+61
-2
lines changed
Binary file not shown.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "philosophical_capybara",
3+
"type": "WARNING",
4+
"input_data": "inGKcf+S3ESO5gI73P////////8BAFBgAABaIP9DjuaC",
5+
"logs": [
6+
"Slow input: 38 seconds for processing",
7+
"artifact_prefix='/tmp/libfuzzer-out-2077056338/'; Test unit written to .cifuzz-findings/philosophical_capybara/crashing-input",
8+
"Base64: inGKcf+S3ESO5gI73P////////8BAFBgAABaIP9DjuaC"
9+
],
10+
"details": "Slow input detected. Processing time: 38 s",
11+
"more_details": {
12+
"id": "slow_input"
13+
},
14+
"created_at": "2024-08-22T09:02:49.692610917Z",
15+
"input_file": ".cifuzz-findings/philosophical_capybara/crashing-input",
16+
"fuzz_test": "slow_input_checks_fuzz_test"
17+
}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ lcov.info
1212

1313
.cifuzz-findings/*
1414
!.cifuzz-findings/awesome_gnu/
15-
16-
.cifuzz-findings/awesome_gnu/.lock
15+
.cifuzz-findings/awesome_gnu/.lock
16+
!.cifuzz-findings/philosophical_capybara/
17+
.cifuzz-findings/philosophical_capybara/.lock

src/advanced_examples/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ endif()
4949
foreach(TestType IN ITEMS
5050
structured_input_checks
5151
custom_mutator_example_checks
52+
slow_input_checks
5253
)
5354

5455
add_executable(${TestType}_test
@@ -69,6 +70,8 @@ foreach(TestType IN ITEMS
6970

7071
add_fuzz_test(${TestType}_fuzz_test
7172
${TestType}_test.cpp
73+
TEST_FRAMEWORK
74+
GTEST
7275
)
7376

7477
target_link_libraries(${TestType}_fuzz_test

src/advanced_examples/explore_me.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <cstring>
22
#include <zlib.h>
3+
#include <iostream>
34
#include "explore_me.h"
45

56
static long insecureEncrypt(long input);
@@ -32,6 +33,20 @@ void ExploreCompressedInputChecks(const uint8_t *Data, size_t Size){
3233
}
3334
}
3435

36+
void ExploreSlowInputsChecks(int a, int b){
37+
if (a == 48664131) {
38+
for (int i = 0; i < b; i++) {
39+
if (i == (b-1)) {
40+
break;
41+
}
42+
43+
if (i % 1000 == 0) {
44+
std::cout << "In loop at position: " << i <<" of " <<b << std::endl;
45+
}
46+
}
47+
}
48+
}
49+
3550
static long insecureEncrypt(long input) {
3651
long key = 0xefe4eb93215cb6b0L;
3752
return input ^ key;

src/advanced_examples/explore_me.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ struct InputStruct {
1717

1818
void ExploreStructuredInputChecks(InputStruct inputStruct);
1919
void ExploreCompressedInputChecks(const uint8_t *Data, size_t Size);
20+
void ExploreSlowInputsChecks(int a, int b);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#include <cifuzz/cifuzz.h>
2+
#include <fuzzer/FuzzedDataProvider.h>
3+
4+
#include "explore_me.h"
5+
#include <gtest/gtest.h>
6+
7+
TEST(ExploreSlowInputsChecks, FirstTest) {
8+
9+
EXPECT_NO_THROW(ExploreSlowInputsChecks(23323, 100));
10+
}
11+
12+
TEST(ExploreSlowInputsChecks, SecondTest) {
13+
EXPECT_NO_THROW(ExploreSlowInputsChecks(1324153, 192198));
14+
}
15+
16+
DEBUG_FINDING(philosophical_capybara)
17+
FUZZ_TEST(const uint8_t *data, size_t size) {
18+
FuzzedDataProvider fdp(data, size);
19+
long a = fdp.ConsumeIntegral<int>();
20+
long b = fdp.ConsumeIntegral<int>();
21+
ExploreSlowInputsChecks(a,b);
22+
}

0 commit comments

Comments
 (0)