--- /dev/null
+#!/bin/sh
+: "${AFL_PREFIX:=afl-}"
+: "${AFL_CC:=afl-gcc}"
+: "${RESULT_DIR:=${AFL_PREFIX}result}"
+
+clean_lib() {
+ echo "🛀 cleaning $1"
+ cd "$1" && make clean all && cd ..
+}
+
+compile() {
+ export CC="$AFL_CC"
+ clean_lib util
+ clean_lib ast
+ clean_lib "$PWD"
+}
+
+prepare() {
+ CRASH_DIR=${AFL_PREFIX}crash
+ if [ -d "$CRASH_DIR" ]
+ then echo "✋ $CRASH_DIR already contains at risk data"
+ else mkdir "$CRASH_DIR"
+ fi
+ for file in "$RESULT_DIR"/*/crashes/id*
+ do
+ NEW_NAME="$(basename "$file" | sed 's/id:0*\([0-9]*\),.*/\1.gw/')"
+ cp "$file" "$NEW_NAME"
+ done
+}
+
+#compile
+prepare
#!/bin/sh
: "${PRG:=./gwion}"
-pahole -s ${PRG} | while read name size gap
-do [ $size -gt 64 ] && echo $name $size
- [ $gap -gt 0 ] && echo "$name has a gap"
+pahole -s ${PRG} | while read -r name size gap
+do [ "$size" -gt 64 ] && echo "$name $size"
+ [ "$gap" -gt 0 ] && echo "$name has a gap"
done
[ -f test.log ] && rm test.log
[ $# -ne 0 ] && do_test "${@}" | consummer
-if [ -f test.log ] && [ -z $NO_LOG ]
+if [ -f test.log ] && [ -z "$NO_LOG" ]
then
cat test.log
exit 1