aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-05-26 15:57:15 +0200
committervan Hauser <vh@thc.org>2020-05-26 15:57:15 +0200
commit9dd0b7c6de72100ceaf99bba3b0705f952b36de0 (patch)
tree2e34711cdc6e463c849432262892459aa59f156b /examples
parent1cae68dde32abf9c7fe83cb9a91890deba973834 (diff)
downloadafl++-9dd0b7c6de72100ceaf99bba3b0705f952b36de0.tar.gz
make examples better
Diffstat (limited to 'examples')
-rw-r--r--examples/aflpp_driver/GNUmakefile8
-rw-r--r--examples/persistent_demo/persistent_demo.c2
-rw-r--r--examples/persistent_demo/persistent_demo_new.c23
3 files changed, 3 insertions, 30 deletions
diff --git a/examples/aflpp_driver/GNUmakefile b/examples/aflpp_driver/GNUmakefile
index fca3fd2c..a681d2cf 100644
--- a/examples/aflpp_driver/GNUmakefile
+++ b/examples/aflpp_driver/GNUmakefile
@@ -9,19 +9,13 @@ endif
FLAGS=-O3 -funroll-loops
-all: libAFLDriver.a libAFLDriver2.a
+all: libAFLDriver.a
aflpp_driver.o: aflpp_driver.cpp
$(LLVM_BINDIR)clang++ $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c aflpp_driver.cpp
-afl-llvm-rt.o: ../../llvm_mode/afl-llvm-rt.o.c
- $(LLVM_BINDIR)clang $(FLAGS) -I../../include -c -o afl-llvm-rt.o ../../llvm_mode/afl-llvm-rt.o.c
-
libAFLDriver.a: aflpp_driver.o
ar ru libAFLDriver.a aflpp_driver.o
-libAFLDriver2.a: aflpp_driver.o afl-llvm-rt.o
- ar ru libAFLDriver2.a aflpp_driver.o afl-llvm-rt.o
-
clean:
rm -f *.o libAFLDriver*.a *~ core
diff --git a/examples/persistent_demo/persistent_demo.c b/examples/persistent_demo/persistent_demo.c
index 41cd9e38..2da49bb0 100644
--- a/examples/persistent_demo/persistent_demo.c
+++ b/examples/persistent_demo/persistent_demo.c
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
We just have some trivial inline code that faults on 'foo!'. */
/* do we have enough data? */
- if (len < 8) return 0;
+ if (len < 8) continue;
if (buf[0] == 'f') {
diff --git a/examples/persistent_demo/persistent_demo_new.c b/examples/persistent_demo/persistent_demo_new.c
index fffd40b6..36411e13 100644
--- a/examples/persistent_demo/persistent_demo_new.c
+++ b/examples/persistent_demo/persistent_demo_new.c
@@ -30,27 +30,6 @@
__AFL_FUZZ_INIT();
-unsigned int crc32_for_byte(unsigned int r) {
-
- for (int j = 0; j < 8; ++j)
- r = (r & 1 ? 0 : (unsigned int)0xEDB88320L) ^ r >> 1;
- return r ^ (unsigned int)0xFF000000L;
-
-}
-
-unsigned int crc32(unsigned char *data, unsigned int n_bytes) {
-
- static unsigned char table[0x100];
- unsigned int crc = 0;
- if (!*table)
- for (unsigned int i = 0; i < 0x100; ++i)
- table[i] = crc32_for_byte(i);
- for (unsigned int i = 0; i < n_bytes; ++i)
- crc = table[(unsigned char)crc ^ (data)[i]] ^ crc >> 8;
- return crc;
-
-}
-
/* Main entry point. */
int main(int argc, char **argv) {
@@ -70,7 +49,7 @@ int main(int argc, char **argv) {
len = __AFL_FUZZ_TESTCASE_LEN;
/* do we have enough data? */
- if (len < 8) return 0;
+ if (len < 8) continue;
if (buf[0] == 'f') {