diff options
author | hexcoder- <heiko@hexco.de> | 2020-03-21 18:51:43 +0100 |
---|---|---|
committer | hexcoder- <heiko@hexco.de> | 2020-03-21 18:51:43 +0100 |
commit | 6cbd0f1faf576a3ba9021720b0ca63a3cdd260ab (patch) | |
tree | fbfadeeea0fcaa55d5b0b43cfbe41cfce5fb74a1 | |
parent | dcd9cd638b186909d86ec3c3c27fdb0ceadd0a04 (diff) | |
download | afl++-6cbd0f1faf576a3ba9021720b0ca63a3cdd260ab.tar.gz |
avoid calling awk for 'which' replacement, use POSIX 'command -v' instead
-rwxr-xr-x | afl-cmin | 4 | ||||
-rwxr-xr-x | afl-plot | 2 | ||||
-rw-r--r-- | gcc_plugin/Makefile | 2 | ||||
-rw-r--r-- | llvm_mode/Makefile | 2 | ||||
-rwxr-xr-x | qemu_mode/build_qemu_support.sh | 2 | ||||
-rwxr-xr-x | test/test.sh | 10 |
6 files changed, 11 insertions, 11 deletions
diff --git a/afl-cmin b/afl-cmin index d96a103f..d38e7a97 100755 --- a/afl-cmin +++ b/afl-cmin @@ -264,7 +264,7 @@ BEGIN { if (target_bin && !exists_and_is_executable(target_bin)) { - "type "target_bin" | awk '{print $NF}' 2>/dev/null" | getline tnew + "command -v "target_bin" 2>/dev/null" | getline tnew if (!tnew || !exists_and_is_executable(tnew)) { print "[-] Error: binary '"target_bin"' not found or not executable." > "/dev/stderr" exit 1 @@ -313,7 +313,7 @@ BEGIN { if (0 == system("test -f afl-cmin")) { showmap = "./afl-showmap" } else { - "type afl-showmap | awk '{print $NF}' 2>/dev/null" | getline showmap + "command -v afl-showmap 2>/dev/null" | getline showmap } } else { showmap = ENVIRON["AFL_PATH"] "/afl-showmap" diff --git a/afl-plot b/afl-plot index b17af364..6ad3f790 100755 --- a/afl-plot +++ b/afl-plot @@ -68,7 +68,7 @@ BANNER="`cat "$1/fuzzer_stats" | grep '^afl_banner ' | cut -d: -f2- | cut -b2-`" test "$BANNER" = "" && BANNER="(none)" -GNUPLOT=`type gnuplot | awk '{print $NF}' 2>/dev/null` +GNUPLOT=`command -v gnuplot 2>/dev/null` if [ "$GNUPLOT" = "" ]; then diff --git a/gcc_plugin/Makefile b/gcc_plugin/Makefile index f1e86d38..506d690d 100644 --- a/gcc_plugin/Makefile +++ b/gcc_plugin/Makefile @@ -44,7 +44,7 @@ PLUGIN_FLAGS = -fPIC -fno-rtti -I"$(shell $(CC) -print-file-name=plugin)/include HASH=\# GCCVER = $(shell $(CC) --version 2>/dev/null | awk 'NR == 1 {print $$NF}') -GCCBINDIR = $(shell dirname `type $(CC) | awk '{print $$NF}'` 2>/dev/null ) +GCCBINDIR = $(shell dirname `command -v $(CC)` 2>/dev/null ) ifeq "$(shell echo '$(HASH)include <sys/ipc.h>@$(HASH)include <sys/shm.h>@int main() { int _id = shmget(IPC_PRIVATE, 65536, IPC_CREAT | IPC_EXCL | 0600); shmctl(_id, IPC_RMID, 0); return 0;}' | tr @ '\n' | $(CC) -x c - -o .test2 2>/dev/null && echo 1 || echo 0 ; rm -f .test2 )" "1" SHMAT_OK=1 diff --git a/llvm_mode/Makefile b/llvm_mode/Makefile index 0dd4f0b5..2b1660a3 100644 --- a/llvm_mode/Makefile +++ b/llvm_mode/Makefile @@ -162,7 +162,7 @@ ifeq "$(shell uname)" "OpenBSD" CLANG_LFL += `$(LLVM_CONFIG) --libdir`/libLLVM.so endif -ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -fuse-ld=`type ld | awk '{print $$NF}'` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" +ifeq "$(shell echo 'int main() {return 0; }' | $(CC) -x c - -fuse-ld=`command -v ld` -o .test 2>/dev/null && echo 1 || echo 0 ; rm -f .test )" "1" CFLAGS += -DAFL_CLANG_FUSELD=1 endif diff --git a/qemu_mode/build_qemu_support.sh b/qemu_mode/build_qemu_support.sh index 021e107b..4cf84477 100755 --- a/qemu_mode/build_qemu_support.sh +++ b/qemu_mode/build_qemu_support.sh @@ -86,7 +86,7 @@ fi if echo "$CC" | grep -qF /afl-; then echo "[-] Error: do not use afl-gcc or afl-clang to compile this tool." - exit 1 + PREREQ_NOTFOUND=1 fi diff --git a/test/test.sh b/test/test.sh index 49dfb1a9..5246a3ec 100755 --- a/test/test.sh +++ b/test/test.sh @@ -223,7 +223,7 @@ test -e ../afl-clang-fast -a -e ../split-switches-pass.so && { # on FreeBSD need to set AFL_CC test `uname -s` = 'FreeBSD' && { if type clang >/dev/null; then - export AFL_CC=`type clang | awk '{print $NF}'` + export AFL_CC=`command -v clang` else export AFL_CC=`$LLVM_CONFIG --bindir`/clang fi @@ -401,7 +401,7 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { # on FreeBSD need to set AFL_CC test `uname -s` = 'FreeBSD' && { if type clang >/dev/null; then - export AFL_CC=`type clang | awk '{print $NF}'` + export AFL_CC=`command -v clang` else export AFL_CC=`$LLVM_CONFIG --bindir`/clang fi @@ -471,7 +471,7 @@ test -e ../afl-clang-lto -a -e ../afl-llvm-lto-instrumentation.so && { } $ECHO "$BLUE[*] Testing: gcc_plugin" -export AFL_CC=`type gcc | awk '{print $NF}'` +export AFL_CC=`command -v gcc` test -e ../afl-gcc-fast -a -e ../afl-gcc-rt.o && { ../afl-gcc-fast -o test-instr.plain.gccpi ../test-instr.c > /dev/null 2>&1 AFL_HARDEN=1 ../afl-gcc-fast -o test-compcov.harden.gccpi test-compcov.c > /dev/null 2>&1 @@ -617,7 +617,7 @@ test -e ../libradamsa.so && { test `uname -s` = 'FreeBSD' && { if type clang >/dev/null; then - export AFL_CC=`type clang | awk '{print $NF}'` + export AFL_CC=`command -v clang` else export AFL_CC=`$LLVM_CONFIG --bindir`/clang fi @@ -835,7 +835,7 @@ test -d ../unicorn_mode/unicornafl && { test -e ../unicorn_mode/samples/simple/simple_target.bin -a -e ../unicorn_mode/samples/compcov_x64/compcov_target.bin && { { # travis workaround - PY=`type python | awk '{print $NF}'` + PY=`command -v python` test "$PY" = "/opt/pyenv/shims/python" -a -x /usr/bin/python && PY=/usr/bin/python mkdir -p in echo 0 > in/in |