about summary refs log tree commit diff
path: root/fix.m4
diff options
context:
space:
mode:
Diffstat (limited to 'fix.m4')
-rw-r--r--fix.m423
1 files changed, 14 insertions, 9 deletions
diff --git a/fix.m4 b/fix.m4
index 4ae99b9..fc7c2ce 100644
--- a/fix.m4
+++ b/fix.m4
@@ -17,7 +17,6 @@
 # You should have received a copy of the GNU Affero General Public License
 # along with taosc.  If not, see <https://www.gnu.org/licenses/>.
 
-set -eux -o pipefail
 save_exit_code() {
   set +e
   timeout -k 1 $1 ${@:2} 1>/dev/null 2>&1
@@ -36,6 +35,8 @@ then
   echo Usage: taosc-fix WORKDIR TIMEOUT EXECUTABLE PROOFS_OF_CONCEPT [OPTION]...
   exit 1
 fi
+
+set -eux -o pipefail
 wd="$(realpath $1)"
 test -d "$wd"
 timeout=$2
@@ -103,7 +104,8 @@ e9tool -100 -M addr=$patch_loc -P 'if dest(state)@patch goto'\
   -o "$bin.patched" "$binary"
 
 # TODO: FUZZOLIC's options
-fuzzolic -kmprst 90000 -i "$poc" -o "$wd/fuzzolic" -- "$binary" $option @@
+fuzzolic -kmprst 90000 -i "$poc" -o "$wd/fuzzolic" -- "$binary" $options @@ ||
+  true # FIXME: failing with the same status as the target program
 rm -fr "$wd/input"
 mkdir -p "$wd/input/benign"
 cp -r "$poc" "$wd/input/malicious"
@@ -127,13 +129,16 @@ do
   output_dir="$wd/values/$(basename "$input_dir")"
   mkdir -p "$output_dir"
   # TODO: use parallel
-  for input in "$input_dir"/*
-  do
-    output="$output_dir/$(basename "$input")"
-    save_exit_code $timeout\
-      env TAOSC_STACK_SIZE=$stack_size TAOSC_OUTPUT=$output\
-      "$bin.collect" $options "$input"
-  done
+  if test "$(ls -A "$input_dir")"
+  then
+    for input in "$input_dir"/*
+    do
+      output="$output_dir/$(basename "$input")"
+      save_exit_code $timeout\
+        env TAOSC_STACK_SIZE=$stack_size TAOSC_OUTPUT=$output\
+        "$bin.collect" $options "$input"
+    done
+  fi
 done
 # TODO: split if the patch location is reached multiple times with an input
 taosc-synth $stack_size "$wd"/values/{benign,malicious} > "$wd/predicates"