about summary refs log tree commit diff
diff options
context:
space:
mode:
-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