Skip to contentSkip to conversation

fuzz: minor changes to libefl fuzzer

PATCH New Wei Liu 1 participant 3 messages Jan 25, 2017

lore
Share & tools
lore
author
#1 lore raw

PATCH 1/2 fuzz/libelf: return early if elf_init fails

In reply to Wei Liu

Coverity-ID: 1399557

---
 tools/fuzz/libelf/libelf-fuzzer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/fuzz/libelf/libelf-fuzzer.c +3 -1
index 71561d3460..1ba8571711 100644
@@ -13,7 +13,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
     elf = &elf_buf;
 
     memset(elf, 0, sizeof(*elf));
-    elf_init(elf, (const char *)data, size);
+    if ( elf_init(elf, (const char *)data, size) < 0 )
+        return -1;
+
     elf_parse_binary(elf);
     elf_xen_parse(elf, &parms);
 
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

Wei Liu

author
#0 lore raw

cover fuzz: minor changes to libefl fuzzer

Prompted by coverity scan.

Wei Liu (2):
fuzz/libelf: return early if elf_init fails fuzz/libelf: exit with fuzzer function return value

 tools/fuzz/libelf/afl-libelf-fuzzer.c | 4 +---
 tools/fuzz/libelf/libelf-fuzzer.c     | 4 +++-
 2 files changed, 4 insertions(+), 4 deletions(-)
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
author
#2 lore raw

PATCH 2/2 fuzz/libelf: exit with fuzzer function return value

Now the function can return nonzero value. Use that value as exit code for the stub program. AFL might be able to use such information to optimise fuzzing process.

---
 tools/fuzz/libelf/afl-libelf-fuzzer.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/fuzz/libelf/afl-libelf-fuzzer.c +1 -3
index b5668c11e7..02cbfb0e2c 100644
@@ -42,9 +42,7 @@ int main(int argc, char **argv)
 
     fclose(fp);
 
-    LLVMFuzzerTestOneInput(input, size);
-
-    return 0;
+    return LLVMFuzzerTestOneInput(input, size);
 }
 
 /*
Signature · 7 lines
2.11.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel