66static long insecureEncrypt (long input);
77static void trigger_global_buffer_overflow (const std::string &c);
88static void trigger_use_after_free ();
9+ static void trigger_double_free ();
10+ static void trigger_memory_leak ();
911
1012void ExploreSimpleChecks (int a, int b, std::string c) {
1113 if (a >= 20000 ) {
@@ -29,6 +31,16 @@ void ExploreComplexChecks(long a, long b, std::string c) {
2931 }
3032}
3133
34+ void ExploreStructuredInputChecks (InputStrut inputStrut){
35+ if (EncodeBase64 (inputStrut.c ) == " SGV5LCB3ZWw=" ) {
36+ if (insecureEncrypt (inputStrut.a ) == 0x4e9e91e6677cfff3L ) {
37+ if (insecureEncrypt (inputStrut.b ) == 0x4f8b9fb34431d9d3L ) {
38+ trigger_double_free ();
39+ }
40+ }
41+ }
42+ }
43+
3244static long insecureEncrypt (long input) {
3345 long key = 0xefe4eb93215cb6b0L ;
3446 return input ^ key;
@@ -47,4 +59,19 @@ static void trigger_use_after_free() {
4759 buffer[5 ] = ' \0 ' ;
4860 free (buffer);
4961 printf (" %s\n " , buffer);
50- }
62+ }
63+
64+ static void trigger_double_free (){
65+ auto *buffer = static_cast <char *>(malloc (6 ));
66+ memcpy (buffer, " hello" , 5 );
67+ buffer[5 ] = ' \0 ' ;
68+ for (int i = 0 ; i < 2 ; i++) {
69+ free (buffer);
70+ }
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+ }
0 commit comments