| OLD | NEW |
| 1 /* | 1 /* |
| 2 american fuzzy lop - test case minimizer | 2 american fuzzy lop - test case minimizer |
| 3 ---------------------------------------- | 3 ---------------------------------------- |
| 4 | 4 |
| 5 Written and maintained by Michal Zalewski <lcamtuf@google.com> | 5 Written and maintained by Michal Zalewski <lcamtuf@google.com> |
| 6 | 6 |
| 7 Copyright 2015, 2016 Google Inc. All rights reserved. | 7 Copyright 2015, 2016 Google Inc. All rights reserved. |
| 8 | 8 |
| 9 Licensed under the Apache License, Version 2.0 (the "License"); | 9 Licensed under the Apache License, Version 2.0 (the "License"); |
| 10 you may not use this file except in compliance with the License. | 10 you may not use this file except in compliance with the License. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 edges_only, /* Ignore hit counts? */ | 74 edges_only, /* Ignore hit counts? */ |
| 75 use_stdin = 1; /* Use stdin for program input? */ | 75 use_stdin = 1; /* Use stdin for program input? */ |
| 76 | 76 |
| 77 static volatile u8 | 77 static volatile u8 |
| 78 stop_soon, /* Ctrl-C pressed? */ | 78 stop_soon, /* Ctrl-C pressed? */ |
| 79 child_timed_out; /* Child timed out? */ | 79 child_timed_out; /* Child timed out? */ |
| 80 | 80 |
| 81 | 81 |
| 82 /* Classify tuple counts. This is a slow & naive version, but good enough here.
*/ | 82 /* Classify tuple counts. This is a slow & naive version, but good enough here.
*/ |
| 83 | 83 |
| 84 #define AREP4(_sym) (_sym), (_sym), (_sym), (_sym) | 84 static const u8 count_class_lookup[256] = { |
| 85 #define AREP8(_sym) AREP4(_sym), AREP4(_sym) | |
| 86 #define AREP16(_sym) AREP8(_sym), AREP8(_sym) | |
| 87 #define AREP32(_sym) AREP16(_sym), AREP16(_sym) | |
| 88 #define AREP64(_sym) AREP32(_sym), AREP32(_sym) | |
| 89 #define AREP128(_sym) AREP64(_sym), AREP64(_sym) | |
| 90 | 85 |
| 91 static u8 count_class_lookup[256] = { | 86 [0] = 0, |
| 92 | 87 [1] = 1, |
| 93 /* 0 - 3: 4 */ 0, 1, 2, 4, | 88 [2] = 2, |
| 94 /* 4 - 7: +4 */ AREP4(8), | 89 [3] = 4, |
| 95 /* 8 - 15: +8 */ AREP8(16), | 90 [4 ... 7] = 8, |
| 96 /* 16 - 31: +16 */ AREP16(32), | 91 [8 ... 15] = 16, |
| 97 /* 32 - 127: +96 */ AREP64(64), AREP32(64), | 92 [16 ... 31] = 32, |
| 98 /* 128+: +128 */ AREP128(128) | 93 [32 ... 127] = 64, |
| 94 [128 ... 255] = 128 |
| 99 | 95 |
| 100 }; | 96 }; |
| 101 | 97 |
| 102 static void classify_counts(u8* mem) { | 98 static void classify_counts(u8* mem) { |
| 103 | 99 |
| 104 u32 i = MAP_SIZE; | 100 u32 i = MAP_SIZE; |
| 105 | 101 |
| 106 if (edges_only) { | 102 if (edges_only) { |
| 107 | 103 |
| 108 while (i--) { | 104 while (i--) { |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 "detect_leaks=0:" | 691 "detect_leaks=0:" |
| 696 "symbolize=0:" | 692 "symbolize=0:" |
| 697 "allocator_may_return_null=1", 0); | 693 "allocator_may_return_null=1", 0); |
| 698 | 694 |
| 699 setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":" | 695 setenv("MSAN_OPTIONS", "exit_code=" STRINGIFY(MSAN_ERROR) ":" |
| 700 "symbolize=0:" | 696 "symbolize=0:" |
| 701 "abort_on_error=1:" | 697 "abort_on_error=1:" |
| 702 "allocator_may_return_null=1:" | 698 "allocator_may_return_null=1:" |
| 703 "msan_track_origins=0", 0); | 699 "msan_track_origins=0", 0); |
| 704 | 700 |
| 705 if (getenv("AFL_LD_PRELOAD")) | 701 if (getenv("AFL_PRELOAD")) { |
| 706 setenv("LD_PRELOAD", getenv("AFL_LD_PRELOAD"), 1); | 702 setenv("LD_PRELOAD", getenv("AFL_PRELOAD"), 1); |
| 703 setenv("DYLD_INSERT_LIBRARIES", getenv("AFL_PRELOAD"), 1); |
| 704 } |
| 707 | 705 |
| 708 } | 706 } |
| 709 | 707 |
| 710 | 708 |
| 711 /* Setup signal handlers, duh. */ | 709 /* Setup signal handlers, duh. */ |
| 712 | 710 |
| 713 static void setup_signal_handlers(void) { | 711 static void setup_signal_handlers(void) { |
| 714 | 712 |
| 715 struct sigaction sa; | 713 struct sigaction sa; |
| 716 | 714 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 ACTF("Writing output to '%s'...", out_file); | 1075 ACTF("Writing output to '%s'...", out_file); |
| 1078 | 1076 |
| 1079 close(write_to_file(out_file, in_data, in_len)); | 1077 close(write_to_file(out_file, in_data, in_len)); |
| 1080 | 1078 |
| 1081 OKF("We're done here. Have a nice day!\n"); | 1079 OKF("We're done here. Have a nice day!\n"); |
| 1082 | 1080 |
| 1083 exit(0); | 1081 exit(0); |
| 1084 | 1082 |
| 1085 } | 1083 } |
| 1086 | 1084 |
| OLD | NEW |