Ghidra is a software reverse engineering (SRE) framework
Prevent segfault from known bash expansion bug
samy kamkard552692fb396
diff --git a/Ghidra/RuntimeScripts/Linux/ghidraRun b/Ghidra/RuntimeScripts/Linux/ghidraRunindex 906fc02ac4..734e28b2d3 100755--- a/Ghidra/RuntimeScripts/Linux/ghidraRun+++ b/Ghidra/RuntimeScripts/Linux/ghidraRun@@ -23,7 +23,6 @@ VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_GUI_JAVA_OPTIONS} "# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Ghidra"${SCRIPT_DIR}"/support/launch.sh bg jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr b/Ghidra/RuntimeScripts/Linux/server/ghidraSvrindex 934063daed..88771a237b 100755--- a/Ghidra/RuntimeScripts/Linux/server/ghidraSvr+++ b/Ghidra/RuntimeScripts/Linux/server/ghidraSvr@@ -75,8 +75,7 @@ WRAPPER_TMPDIR="${TMPDIR:-/tmp}"# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Ensure Ghidra path doesn't contain illegal charactersif [[ "${SCRIPT_DIR}" = *"!"* ]]; thenecho "Ghidra path cannot contain a \"!\" character."diff --git a/Ghidra/RuntimeScripts/Linux/server/svrAdmin b/Ghidra/RuntimeScripts/Linux/server/svrAdminindex d0ae587e11..ee9f35bb4c 100755--- a/Ghidra/RuntimeScripts/Linux/server/svrAdmin+++ b/Ghidra/RuntimeScripts/Linux/server/svrAdmin@@ -31,8 +31,7 @@ MAXMEM=128M# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"if [ -d "${SCRIPT_DIR}/../Ghidra" ]; then# Production EnvironmentCONFIG="${SCRIPT_DIR}/server.conf"diff --git a/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo b/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGoindex 53989fe65f..47f5f2c6a4 100755--- a/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo+++ b/Ghidra/RuntimeScripts/Linux/support/GhidraGo/ghidraGo@@ -10,7 +10,6 @@ LAUNCH_MODE=fg# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Filesystem Conversion"${SCRIPT_DIR}"/../launch.sh $LAUNCH_MODE jdk GhidraGo "" "" ghidra.GhidraGo "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadlessindex 342d69c7a6..cf2c74c264 100755--- a/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless+++ b/Ghidra/RuntimeScripts/Linux/support/analyzeHeadless@@ -36,8 +36,7 @@ DEBUG_ADDRESS=127.0.0.1:13002# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch HeadlessAnalyzer.# DEBUG_ADDRESS set via environment for launch.shDEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${GHIDRA_HEADLESS_MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim b/Ghidra/RuntimeScripts/Linux/support/bsimindex c8bbcdb776..638d026797 100755--- a/Ghidra/RuntimeScripts/Linux/support/bsim+++ b/Ghidra/RuntimeScripts/Linux/support/bsim@@ -27,6 +27,5 @@ LAUNCH_MODE=fg# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSim" "${GHIDRA_BSIM_MAXMEM}" "${VMARG_LIST}" ghidra.features.bsim.query.ingest.BSimLaunchable "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl b/Ghidra/RuntimeScripts/Linux/support/bsim_ctlindex 2df6745b1d..d5f10a91bd 100755--- a/Ghidra/RuntimeScripts/Linux/support/bsim_ctl+++ b/Ghidra/RuntimeScripts/Linux/support/bsim_ctl@@ -15,6 +15,5 @@ VMARG_LIST="-Djava.awt.headless=true "# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"${SCRIPT_DIR}/launch.sh $LAUNCH_MODE jdk "BSimControl" $MAXMEM "${VMARG_LIST}" ghidra.features.bsim.query.BSimControlLaunchable "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJarindex ad6bafa91b..7d8314fdf2 100755--- a/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar+++ b/Ghidra/RuntimeScripts/Linux/support/buildGhidraJar@@ -16,8 +16,7 @@ LAUNCH_MODE=fg# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"GHIDRA_ROOT_DIR="${SCRIPT_DIR}"/../Ghidraif [ ! -d "${GHIDRA_ROOT_DIR}" ]; thenecho "This script does not support development mode use"diff --git a/Ghidra/RuntimeScripts/Linux/support/convertStorage b/Ghidra/RuntimeScripts/Linux/support/convertStorageindex 010a72e50c..72722ee1a2 100755--- a/Ghidra/RuntimeScripts/Linux/support/convertStorage+++ b/Ghidra/RuntimeScripts/Linux/support/convertStorage@@ -13,7 +13,6 @@ MAXMEM=128M# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Filesystem Conversion"${SCRIPT_DIR}"/launch.sh fg jdk ConvertStorage "${MAXMEM}" "" ghidra.framework.data.ConvertFileSystem "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun b/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRunindex 52f77d7b60..7b3baa0556 100755--- a/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun+++ b/Ghidra/RuntimeScripts/Linux/support/gdbGADPServerRun@@ -13,7 +13,6 @@# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Ghidra"${SCRIPT_DIR}"/launch.sh fg jdk GdbAgent "${MAXMEM}" "" agent.gdb.gadp.GdbGadpServerLaunchShim $@diff --git a/Ghidra/RuntimeScripts/Linux/support/ghidraClean b/Ghidra/RuntimeScripts/Linux/support/ghidraCleanindex b6b0ecc85e..be89ab2fda 100755--- a/Ghidra/RuntimeScripts/Linux/support/ghidraClean+++ b/Ghidra/RuntimeScripts/Linux/support/ghidraClean@@ -16,6 +16,5 @@ VMARG_LIST="-Djava.awt.headless=true "# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)""${SCRIPT_DIR}"/launch.sh fg jre Ghidra-Clean "$MAXMEM" "$VMARG_LIST" utility.application.AppCleaner Ghidradiff --git a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug b/Ghidra/RuntimeScripts/Linux/support/ghidraDebugindex 2b7e46abd5..bd1347745b 100755--- a/Ghidra/RuntimeScripts/Linux/support/ghidraDebug+++ b/Ghidra/RuntimeScripts/Linux/support/ghidraDebug@@ -30,8 +30,7 @@ DEBUG_ADDRESS=127.0.0.1:18001# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Ghidra in debug mode# DEBUG_ADDRESS set via environment for launch.shDEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/jshellRun b/Ghidra/RuntimeScripts/Linux/support/jshellRunindex fa9eda6a0c..69850ceac4 100755--- a/Ghidra/RuntimeScripts/Linux/support/jshellRun+++ b/Ghidra/RuntimeScripts/Linux/support/jshellRun@@ -23,7 +23,6 @@ VMARG_LIST="${GHIDRA_JAVA_OPTIONS} ${GHIDRA_JSHELL_JAVA_OPTIONS} "# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Ghidra"${SCRIPT_DIR}"/launch.sh fg jdk Ghidra-JShell "${GHIDRA_JSHELL_MAXMEM}" "${VMARG_LIST}" ghidra.JShellRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/jythonRun b/Ghidra/RuntimeScripts/Linux/support/jythonRunindex 89cf5b4bf5..f211460b47 100755--- a/Ghidra/RuntimeScripts/Linux/support/jythonRun+++ b/Ghidra/RuntimeScripts/Linux/support/jythonRun@@ -35,8 +35,7 @@ DEBUG_ADDRESS=127.0.0.1:13002# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Launch Ghidra Jython# DEBUG_ADDRESS set via environment for launch.shDEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Jython" "${GHIDRA_JYTHON_MAXMEM}" "${VMARG_LIST}" ghidra.jython.JythonRun "$@"diff --git a/Ghidra/RuntimeScripts/Linux/support/launch.sh b/Ghidra/RuntimeScripts/Linux/support/launch.shindex de274efd30..ac4b73a78c 100755--- a/Ghidra/RuntimeScripts/Linux/support/launch.sh+++ b/Ghidra/RuntimeScripts/Linux/support/launch.sh@@ -93,8 +93,7 @@ if [[ ${INDEX} -lt 6 ]]; thenfi# Sets SUPPORT_DIR to the directory that contains this file (launch.sh)-SUPPORT_DIR="${0%/*}"-+SUPPORT_DIR="$(cd "$(dirname "$0")" && pwd)"# Ensure Ghidra path doesn't contain illegal charactersif [[ "${SUPPORT_DIR}" = *"!"* ]]; thenecho "Ghidra path cannot contain a \"!\" character."diff --git a/Ghidra/RuntimeScripts/Linux/support/pyghidraRun b/Ghidra/RuntimeScripts/Linux/support/pyghidraRunindex ba617b0b50..03cd1a2f7e 100755--- a/Ghidra/RuntimeScripts/Linux/support/pyghidraRun+++ b/Ghidra/RuntimeScripts/Linux/support/pyghidraRun@@ -9,8 +9,7 @@# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)"# Since JPype doesn't seem to pick up JDK_JAVA_OPTIONS automatically, include it ourselvesVMARG_LIST="${JDK_JAVA_OPTIONS}"diff --git a/Ghidra/RuntimeScripts/Linux/support/sleigh b/Ghidra/RuntimeScripts/Linux/support/sleighindex 0f8fa20d21..2974c38d79 100755--- a/Ghidra/RuntimeScripts/Linux/support/sleigh+++ b/Ghidra/RuntimeScripts/Linux/support/sleigh@@ -15,6 +15,5 @@ VMARG_LIST="-Djava.awt.headless=true "# contains the link you are calling (which is the best we can do on macOS), and the "echo" is the# fallback, which doesn't attempt to do anything with links.SCRIPT_FILE="$(readlink -f "$0" 2>/dev/null || readlink "$0" 2>/dev/null || echo "$0")"-SCRIPT_DIR="${SCRIPT_FILE%/*}"-+SCRIPT_DIR="$(cd "$(dirname "$SCRIPT_FILE")" && pwd)""${SCRIPT_DIR}"/launch.sh fg jdk Sleigh "$MAXMEM" "${VMARG_LIST}" ghidra.pcodeCPort.slgh_compile.SleighCompileLauncher "$@"