From 0a9752305d02dbb000f155dcc5fba2818f400727 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Fri, 15 May 2026 09:39:19 +0200 Subject: [PATCH] cc.sh: avoid eval in bell check Signed-off-by: Harmen Stoppels --- cc.sh | 8 +++++--- test/run.sh | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/cc.sh b/cc.sh index d3889c8..bc7afe7 100755 --- a/cc.sh +++ b/cc.sh @@ -208,9 +208,11 @@ execute() { } # Fail with a clear message if the input contains any bell characters. -if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then - die "Compiler command line contains our separator ('${lsep}'). Cannot parse." -fi +case "$*" in + *"$lsep"*) + die "Compiler command line contains our separator ('${lsep}'). Cannot parse." + ;; +esac # ensure required variables are set for param in $params; do diff --git a/test/run.sh b/test/run.sh index 2dd28c8..2a6958b 100644 --- a/test/run.sh +++ b/test/run.sh @@ -363,6 +363,19 @@ test_no_wrapper_environment() { esac } +test_separator_in_args() { + wrapper_environment + _out=$("$WRAPPER_DIR/cc" "hello$(printf '\a')world" 2>&1) + _rc=$? + if [ "$_rc" -eq 0 ]; then + fail "cc with bell char in args unexpectedly exited 0" + fi + case "$_out" in + *"Compiler command line contains our separator"*) ;; + *) fail "expected 'Compiler command line contains our separator' in: $_out" ;; + esac +} + test_modes() { wrapper_environment @@ -1017,6 +1030,7 @@ expected: $_expected_LR" all_tests=' test_no_wrapper_environment +test_separator_in_args test_modes test_expected_args test_expected_args_with_flags