[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 6/7] fuzz/x86emul: print out minimal input size



... so that users can know how big the initial input should be.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 .../fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c  | 8 ++++++++
 tools/fuzz/x86_instruction_emulator/x86-insn-emulator-fuzzer.c    | 5 +++++
 2 files changed, 13 insertions(+)

diff --git a/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c 
b/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
index b5668c11e7..655315f9c1 100644
--- a/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
+++ b/tools/fuzz/x86_instruction_emulator/afl-x86-insn-emulator-fuzzer.c
@@ -2,8 +2,10 @@
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 
 extern int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size);
+extern unsigned int fuzz_minimal_input_size(void);
 
 #define INPUT_SIZE  4096
 static uint8_t input[INPUT_SIZE];
@@ -19,6 +21,12 @@ int main(int argc, char **argv)
         exit(-1);
     }
 
+    if ( !strcmp(argv[1], "--min-input-size") )
+    {
+        printf("%u\n", fuzz_minimal_input_size());
+        exit(0);
+    }
+
     fp = fopen(argv[1], "rb");
     if ( fp == NULL )
     {
diff --git a/tools/fuzz/x86_instruction_emulator/x86-insn-emulator-fuzzer.c 
b/tools/fuzz/x86_instruction_emulator/x86-insn-emulator-fuzzer.c
index 8ca0421f60..3a731b28f2 100644
--- a/tools/fuzz/x86_instruction_emulator/x86-insn-emulator-fuzzer.c
+++ b/tools/fuzz/x86_instruction_emulator/x86-insn-emulator-fuzzer.c
@@ -717,6 +717,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t 
size)
     return 0;
 }
 
+unsigned int fuzz_minimal_input_size(void)
+{
+    return DATA_OFFSET + 1;
+}
+
 /*
  * Local variables:
  * mode: C
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.