Skip to content

Commit 7526ecc

Browse files
committed
cleaned the advanced example file up
1 parent fb6545d commit 7526ecc

File tree

2 files changed

+2
-49
lines changed

2 files changed

+2
-49
lines changed

src/advanced_examples/explore_me.cpp

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,7 @@
33
#include "explore_me.h"
44

55
static long insecureEncrypt(long input);
6-
static void trigger_global_buffer_overflow(const std::string &c);
7-
static void trigger_use_after_free();
86
static void trigger_double_free();
9-
static void trigger_memory_leak();
10-
11-
void ExploreSimpleChecks(int a, int b, std::string c) {
12-
if (a >= 20000) {
13-
if (b >= 2000000) {
14-
if (b - a < 100000) {
15-
if (c == "Attacker") {
16-
trigger_global_buffer_overflow(c);
17-
}
18-
}
19-
}
20-
}
21-
}
227

238
void ExploreStructuredInputChecks(InputStruct inputStruct){
249
if (inputStruct.c == "Attacker") {
@@ -30,48 +15,16 @@ void ExploreStructuredInputChecks(InputStruct inputStruct){
3015
}
3116
}
3217

33-
void ExploreCustomMutatorExampleChecks(SpecialRequirementsStruct* specialRequirementsStruct){
34-
printf("Hello!\n");
35-
strncpy(specialRequirementsStruct->c, "Hello\0", specialRequirementsStruct->c_size);
36-
37-
if (insecureEncrypt(specialRequirementsStruct->a) == 0x4e9e91e6677cfff3L) {
38-
if (insecureEncrypt(specialRequirementsStruct->b) == 0x4f8b9fb34431d9d3L) {
39-
trigger_memory_leak();
40-
}
41-
}
42-
}
43-
4418
static long insecureEncrypt(long input) {
4519
long key = 0xefe4eb93215cb6b0L;
4620
return input ^ key;
4721
}
4822

49-
char gBuffer[5] = {0};
50-
51-
static void trigger_global_buffer_overflow(const std::string &c) {
52-
memcpy(gBuffer, c.c_str(), c.length());
53-
printf("%s\n", gBuffer);
54-
}
55-
56-
static void trigger_use_after_free() {
57-
auto *buffer = static_cast<char *>(malloc(6));
58-
memcpy(buffer, "hello", 5);
59-
buffer[5] = '\0';
60-
free(buffer);
61-
printf("%s\n", buffer);
62-
}
63-
6423
static void trigger_double_free(){
6524
auto *buffer = static_cast<char *>(malloc(6));
6625
memcpy(buffer, "hello", 5);
6726
buffer[5] = '\0';
6827
for (int i = 0; i < 2; i++) {
6928
free(buffer);
7029
}
71-
}
72-
73-
static void trigger_memory_leak(){
74-
auto *buffer = static_cast<char *>(malloc(6));
75-
memcpy(buffer, "hello", 5);
76-
buffer[5] = '\0';
77-
}
30+
}

src/advanced_examples/explore_me.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@ struct SpecialRequirementsStruct {
2020
char* c;
2121
};
2222

23-
void ExploreStructuredInputChecks(InputStruct inputStrut);
23+
void ExploreStructuredInputChecks(InputStruct inputStruct);
2424

2525
void ExploreCustomMutatorExampleChecks(SpecialRequirementsStruct* specialRequirementsStruct);

0 commit comments

Comments
 (0)