about summary refs log tree commit diff
path: root/custom_mutators/simple_mutator.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2019-09-05 10:10:25 +0200
committervan Hauser <vh@thc.org>2019-09-05 10:10:25 +0200
commit760416c1a0a4e3f3261dfee01c3fe11101c4b4ff (patch)
tree32721f67768a4fa12162211e1d7d8485f9e5b4fc /custom_mutators/simple_mutator.c
parent5955dd4e25c9f7dd46e19ea246b14734822d1759 (diff)
downloadafl++-760416c1a0a4e3f3261dfee01c3fe11101c4b4ff.tar.gz
small adjustments for custom mutator
Diffstat (limited to 'custom_mutators/simple_mutator.c')
-rw-r--r--custom_mutators/simple_mutator.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/custom_mutators/simple_mutator.c b/custom_mutators/simple_mutator.c
index 5c40d462..bf655679 100644
--- a/custom_mutators/simple_mutator.c
+++ b/custom_mutators/simple_mutator.c
@@ -3,9 +3,10 @@
 
   Written by Khaled Yakdan <yakdan@code-intelligence.de>
 
-  This a simple mutator that assumes that the generates messages starting with one
-  of the three strings GET, PUT, or DEL followed by a payload. The mutator randomly
-  selects a commend and mutates the payload of the seed provided as input.
+  This a simple mutator that assumes that the generates messages starting with
+  one of the three strings GET, PUT, or DEL followed by a payload. The mutator
+  randomly selects a commend and mutates the payload of the seed provided as
+  input.
 */
 
 #include <stdint.h>
@@ -13,28 +14,36 @@
 #include <string.h>
 
 static const char *commands[] = {
-  "GET",
-  "PUT",
-  "DEL",
+
+    "GET",
+    "PUT",
+    "DEL",
+
 };
 
 static size_t data_size = 100;
 
-size_t afl_custom_mutator (uint8_t *data, size_t size, uint8_t* mutated_out, size_t max_size, unsigned int seed) {
+size_t afl_custom_mutator(uint8_t *data, size_t size, uint8_t *mutated_out,
+                          size_t max_size, unsigned int seed) {
 
   // Seed the PRNG
   srand(seed);
 
-  // Make sure that the packet size does not exceed the maximum size expected by the fuzzer
+  // Make sure that the packet size does not exceed the maximum size expected by
+  // the fuzzer
   size_t mutated_size = data_size <= max_size ? data_size : max_size;
 
   // Randomly select a command string to add as a header to the packet
   memcpy(mutated_out, commands[rand() % 3], 3);
 
   // Mutate the payload of the packet
-  for (int i = 3 ; i < mutated_size ; i++) {
+  for (int i = 3; i < mutated_size; i++) {
+
     mutated_out[i] = (data[i] + rand() % 10) & 0xff;
+
   }
 
   return mutated_size;
+
 }
+