aboutsummaryrefslogtreecommitdiff
path: root/test/test-cmplog.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2021-11-07 14:09:09 +0100
committerGitHub <noreply@github.com>2021-11-07 14:09:09 +0100
commitfb443eaf2372ccd1825699c978fd0d662155fb9e (patch)
treeff019fc0b0704c16d68655d0f3864ec4cda49d30 /test/test-cmplog.c
parent5b06413a5f109f310a62e36111a18d7325b246c3 (diff)
parent2ddbaa439ca78b0ae8cc6691d9657f5783b2d5e8 (diff)
downloadafl++-fb443eaf2372ccd1825699c978fd0d662155fb9e.tar.gz
Merge pull request #1141 from AFLplusplus/afl4
cmplog enhancement variant
Diffstat (limited to 'test/test-cmplog.c')
-rw-r--r--test/test-cmplog.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/test/test-cmplog.c b/test/test-cmplog.c
index b077e3ab..262df6bd 100644
--- a/test/test-cmplog.c
+++ b/test/test-cmplog.c
@@ -1,15 +1,13 @@
#include <stdio.h>
#include <string.h>
+#include <stdint.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
-int main(int argc, char *argv[]) {
- char buf[1024];
- ssize_t i;
- if ((i = read(0, buf, sizeof(buf) - 1)) < 24) return 0;
- buf[i] = 0;
+int LLVMFuzzerTestOneInput(const uint8_t *buf, size_t i) {
+ if (i < 24) return 0;
if (buf[0] != 'A') return 0;
if (buf[1] != 'B') return 0;
if (buf[2] != 'C') return 0;
@@ -18,6 +16,17 @@ int main(int argc, char *argv[]) {
if (strncmp(buf + 12, "IJKL", 4) == 0 && strcmp(buf + 16, "DEADBEEF") == 0)
abort();
return 0;
-
}
+#ifdef __AFL_COMPILER
+int main(int argc, char *argv[]) {
+ unsigned char buf[1024];
+ ssize_t i;
+ while(__AFL_LOOP(1000)) {
+ i = read(0, (char*)buf, sizeof(buf) - 1);
+ if (i > 0) buf[i] = 0;
+ LLVMFuzzerTestOneInput(buf, i);
+ }
+ return 0;
+}
+#endif