diff options
| -rw-r--r-- | qemu_mode/libcompcov/compcovtest.cc | 27 |
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;
- +
}
- +
|
