diff options
author | Andrea Fioraldi <andreafioraldi@gmail.com> | 2019-09-22 19:38:57 +0200 |
---|---|---|
committer | Andrea Fioraldi <andreafioraldi@gmail.com> | 2019-09-22 19:38:57 +0200 |
commit | 9aefe7a0402d4389aaff1f070c84ea1b95abc0fd (patch) | |
tree | 9e0f9f008d7a41c43a09304e8bb5364a14a8d75e /experimental/persistent_demo/persistent_demo.c | |
parent | 17bb51756faeaeda6fb17d63ede0a1a9d8ae4b5c (diff) | |
parent | 5044bb0332bf2bed8fe8691f411bd9c144e332af (diff) | |
download | afl++-9aefe7a0402d4389aaff1f070c84ea1b95abc0fd.tar.gz |
Merge branch 'master' of github.com:vanhauser-thc/AFLplusplus
Diffstat (limited to 'experimental/persistent_demo/persistent_demo.c')
-rw-r--r-- | experimental/persistent_demo/persistent_demo.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/experimental/persistent_demo/persistent_demo.c b/experimental/persistent_demo/persistent_demo.c index 0b1e2989..d091febe 100644 --- a/experimental/persistent_demo/persistent_demo.c +++ b/experimental/persistent_demo/persistent_demo.c @@ -33,6 +33,7 @@ int main(int argc, char** argv) { + ssize_t len; /* how much input did we read? */ char buf[100]; /* Example-only buffer, you'd replace it with other global or local variables appropriate for your use case. */ @@ -57,11 +58,15 @@ int main(int argc, char** argv) { Beware of reading from buffered FILE* objects such as stdin. Use raw file descriptors or call fopen() / fdopen() in every pass. */ - read(0, buf, 100); + len = read(0, buf, 100); /* STEP 3: This is where we'd call the tested library on the read data. We just have some trivial inline code that faults on 'foo!'. */ + /* do we have enough data? */ + if (len < 4) + return 0; + if (buf[0] == 'f') { printf("one\n"); if (buf[1] == 'o') { |