about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhexcoder- <heiko@hexco.de>2020-01-22 18:38:41 +0100
committerhexcoder- <heiko@hexco.de>2020-01-22 18:38:41 +0100
commit7ce627c92e9b0536e254422d5ef604c3f58e43ce (patch)
treee0174445a5c59d6de45683094dd02cc42dffead4
parent44bf5bf262cd46a63f8cd05deee9d1e431c692d6 (diff)
downloadafl++-7ce627c92e9b0536e254422d5ef604c3f58e43ce.tar.gz
Oops, only this version works with FreeBSD, OpenBSD, NetBSD, MacOS, raspbian
-rwxr-xr-xafl-cmin.awk9
1 files changed, 7 insertions, 2 deletions
diff --git a/afl-cmin.awk b/afl-cmin.awk
index 021f7059..28c460e8 100755
--- a/afl-cmin.awk
+++ b/afl-cmin.awk
@@ -110,7 +110,6 @@ function exists_and_is_executable(binarypath) {
 
 BEGIN {
   print "corpus minimization tool for afl-fuzz++ (awk version)\n"
-print "PATH="ENVIRON["PATH"]
 
   # defaults
   extra_par = ""
@@ -302,7 +301,13 @@ print "PATH="ENVIRON["PATH"]
   
   # get list of input filenames sorted by size
   i = 0
-  while ("find "in_dir" -type f -exec stat -f '%z %N' \{\} \; | sort -n | cut -d' ' -f2-" | getline) {
+  # yuck, gnu stat is incompatible to bsd stat
+  if ("stat --version 2>/dev/null" !~ /GNU coreutils/) {
+    stat_format = "-f '%z %N'"
+  } else {
+    stat_format = "-c '%s %n'"
+  }
+  while ("cd "in_dir" && find . -type f -exec stat "stat_format" \{\} \\; | sort -n | cut -d' ' -f2-" | getline) {
     infilesSmallToBig[i++] = $0
   }
   in_count = i