mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 23:27:02 +08:00
Prevent segfault from known bash expansion bug
ghidraRun (and launch.sh) both seg fault in some macOS bash installations via the bash expansions performed in in ghidraRun, launch.sh, and a few other scripts. This happens on my macports bash installation and has been reported in homebrew bash installations as well (https://github.com/orgs/Homebrew/discussions/6270) My specific bash that seg faults: GNU bash, version 5.3.9(1)-release (aarch64-apple-darwin24.6.0) We can avoid the expansion and use an alternate expansion method. Scripts were updated via: ```sh perl -pi -e 's~^(\w+)\s*=\s*"\$\{(\w+)%/\*\}"\s*$~$1="\$(cd "\$(dirname "\$$2")" && pwd)"~' `find Ghidra/RuntimeScripts/Linux/` ```
This commit is contained in:
@@ -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 "$@"
|
||||
|
||||
@@ -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.sh
|
||||
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra-Headless "${GHIDRA_HEADLESS_MAXMEM}" "${VMARG_LIST}" ghidra.app.util.headless.AnalyzeHeadless "$@"
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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}"/../Ghidra
|
||||
if [ ! -d "${GHIDRA_ROOT_DIR}" ]; then
|
||||
echo "This script does not support development mode use"
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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 $@
|
||||
|
||||
@@ -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 Ghidra
|
||||
|
||||
@@ -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.sh
|
||||
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk Ghidra "${GHIDRA_GUI_MAXMEM}" "${VMARG_LIST}" ghidra.GhidraRun "$@"
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
@@ -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.sh
|
||||
DEBUG_ADDRESS=${DEBUG_ADDRESS} "${SCRIPT_DIR}"/launch.sh "${LAUNCH_MODE}" jdk "Ghidra-Jython" "${GHIDRA_JYTHON_MAXMEM}" "${VMARG_LIST}" ghidra.jython.JythonRun "$@"
|
||||
|
||||
@@ -93,8 +93,7 @@ if [[ ${INDEX} -lt 6 ]]; then
|
||||
fi
|
||||
|
||||
# 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 characters
|
||||
if [[ "${SUPPORT_DIR}" = *"!"* ]]; then
|
||||
echo "Ghidra path cannot contain a \"!\" character."
|
||||
|
||||
@@ -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 ourselves
|
||||
VMARG_LIST="${JDK_JAVA_OPTIONS}"
|
||||
|
||||
|
||||
@@ -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 "$@"
|
||||
|
||||
Reference in New Issue
Block a user