33#include " explore_me.h"
44
55static long insecureEncrypt (long input);
6- static void trigger_global_buffer_overflow (const std::string &c);
7- static void trigger_use_after_free ();
86static 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
238void 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-
4418static 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-
6423static 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+ }
0 commit comments