mirror of
https://github.com/AFLplusplus/AFLplusplus.git
synced 2025-06-21 05:42:12 +00:00
make examples better
This commit is contained in:
@ -9,19 +9,13 @@ endif
|
|||||||
|
|
||||||
FLAGS=-O3 -funroll-loops
|
FLAGS=-O3 -funroll-loops
|
||||||
|
|
||||||
all: libAFLDriver.a libAFLDriver2.a
|
all: libAFLDriver.a
|
||||||
|
|
||||||
aflpp_driver.o: aflpp_driver.cpp
|
aflpp_driver.o: aflpp_driver.cpp
|
||||||
$(LLVM_BINDIR)clang++ $(FLAGS) -stdlib=libc++ -funroll-loops -std=c++11 -c 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
|
libAFLDriver.a: aflpp_driver.o
|
||||||
ar ru 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:
|
clean:
|
||||||
rm -f *.o libAFLDriver*.a *~ core
|
rm -f *.o libAFLDriver*.a *~ core
|
||||||
|
@ -63,7 +63,7 @@ int main(int argc, char **argv) {
|
|||||||
We just have some trivial inline code that faults on 'foo!'. */
|
We just have some trivial inline code that faults on 'foo!'. */
|
||||||
|
|
||||||
/* do we have enough data? */
|
/* do we have enough data? */
|
||||||
if (len < 8) return 0;
|
if (len < 8) continue;
|
||||||
|
|
||||||
if (buf[0] == 'f') {
|
if (buf[0] == 'f') {
|
||||||
|
|
||||||
|
@ -30,27 +30,6 @@
|
|||||||
|
|
||||||
__AFL_FUZZ_INIT();
|
__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. */
|
/* Main entry point. */
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
@ -70,7 +49,7 @@ int main(int argc, char **argv) {
|
|||||||
len = __AFL_FUZZ_TESTCASE_LEN;
|
len = __AFL_FUZZ_TESTCASE_LEN;
|
||||||
|
|
||||||
/* do we have enough data? */
|
/* do we have enough data? */
|
||||||
if (len < 8) return 0;
|
if (len < 8) continue;
|
||||||
|
|
||||||
if (buf[0] == 'f') {
|
if (buf[0] == 'f') {
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@ main() {
|
|||||||
while (__AFL_LOOP(10000)) {
|
while (__AFL_LOOP(10000)) {
|
||||||
|
|
||||||
int len = __AFL_FUZZ_TESTCASE_LEN;
|
int len = __AFL_FUZZ_TESTCASE_LEN;
|
||||||
|
if (len < 8) continue; // check for a required/useful minimum input length
|
||||||
if (len < 8) return 0; // check for a required/useful minimum input length
|
|
||||||
|
|
||||||
/* Setup function call, e.g. struct target *tmp = libtarget_init() */
|
/* Setup function call, e.g. struct target *tmp = libtarget_init() */
|
||||||
/* Call function to be fuzzed, e.g.: */
|
/* Call function to be fuzzed, e.g.: */
|
||||||
|
Reference in New Issue
Block a user