about summary refs log tree commit diff
path: root/test/test-floatingpoint.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-07-29 11:39:00 +0200
committerGitHub <noreply@github.com>2020-07-29 11:39:00 +0200
commit4550613f58342632061944ef09add63240d774cc (patch)
tree7896b5ec1f49b3ebe32d1466e85ea8f536ad599e /test/test-floatingpoint.c
parentff107714f1af1bd908a35ce54701da1eca8ce25d (diff)
parent015fde3703c7b67ee65d74b0f4b7b68b5d1e4d7e (diff)
downloadafl++-4550613f58342632061944ef09add63240d774cc.tar.gz
Merge branch 'dev' into text_inputs
Diffstat (limited to 'test/test-floatingpoint.c')
-rw-r--r--test/test-floatingpoint.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/test/test-floatingpoint.c b/test/test-floatingpoint.c
index 8f691c2c..acecd55a 100644
--- a/test/test-floatingpoint.c
+++ b/test/test-floatingpoint.c
@@ -1,16 +1,22 @@
 #include <stdlib.h>
 #include <unistd.h>
+#include <limits.h>
+#include <stdint.h>
+
+__AFL_FUZZ_INIT();
 
 int main(void) {
 
-  float magic;
+  ssize_t bytes_read;
+
+  __AFL_INIT();
+  float *magic = (float *)__AFL_FUZZ_TESTCASE_BUF;
 
-  ssize_t bytes_read = read(STDIN_FILENO, &magic, sizeof(magic));
-  if (bytes_read < (ssize_t)sizeof(magic)) { return 1; }
+  while (__AFL_LOOP(INT_MAX)) {
 
-  if ((-magic == 15.0 + 0.5 + 0.125 + 0.03125 +
-                     0.0078125)) {         /* 15 + 1/2 + 1/8 + 1/32 + 1/128 */
-    abort();
+    if (__AFL_FUZZ_TESTCASE_LEN != sizeof(float)) return 1;
+    /* 15 + 1/2 + 1/8 + 1/32 + 1/128 */
+    if ((-*magic == 15.0 + 0.5 + 0.125 + 0.03125 + 0.0078125)) abort();
 
   }