aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrea Fioraldi <andreafioraldi@gmail.com>2021-04-15 14:42:54 +0200
committerAndrea Fioraldi <andreafioraldi@gmail.com>2021-04-15 14:42:54 +0200
commitd0390f3b7651efefeecf80ebf2b1a740c077f21f (patch)
tree8bbf05f8c30b7a7249767b7c2fc301cc6e6d99b2
parent9d3a2b693a8725983a809af3799b190781130c30 (diff)
downloadafl++-d0390f3b7651efefeecf80ebf2b1a740c077f21f.tar.gz
fix compcovtest
-rw-r--r--qemu_mode/libcompcov/compcovtest.cc27
1 files changed, 17 insertions, 10 deletions
diff --git a/qemu_mode/libcompcov/compcovtest.cc b/qemu_mode/libcompcov/compcovtest.cc
index d70bba91..8346c5b9 100644
--- a/qemu_mode/libcompcov/compcovtest.cc
+++ b/qemu_mode/libcompcov/compcovtest.cc
@@ -20,22 +20,29 @@
// solution: echo -ne 'The quick brown fox jumps over the lazy
// dog\xbe\xba\xfe\xca\xbe\xba\xfe\xca\xde\xc0\xad\xde\xef\xbe' | ./compcovtest
+#include "../../include/config.h"
+
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
-int main() {
-
- char buffer[44] = {/* zero padding */};
- fread(buffer, 1, sizeof(buffer) - 1, stdin);
+int main(int argc, char**argv) {
+
+ static char buffer[MAX_FILE] = {/* zero padding */};
+
+ FILE* file = stdin;
+ if (argc > 1)
+ file = fopen(argv[1], "r");
+
+ fread(buffer, 1, sizeof(buffer) - 1, file);
if (memcmp(&buffer[0], "The quick brown fox ", 20) != 0 ||
strncmp(&buffer[20], "jumps over ", 11) != 0 ||
strcmp(&buffer[31], "the lazy dog") != 0) {
-
+
return 1;
-
+
}
uint64_t x = 0;
@@ -50,18 +57,18 @@ int main() {
fread(&z, sizeof(z), 1, stdin);
switch (z) {
-
+
case 0xBEEF:
break;
default:
return 4;
-
+
}
printf("Puzzle solved, congrats!\n");
abort();
return 0;
-
+
}
-
+