Skip to content

Commit 0a97523

Browse files
committed
cc.sh: avoid eval in bell check
Signed-off-by: Harmen Stoppels <harmenstoppels@gmail.com>
1 parent e47dd22 commit 0a97523

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

cc.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,11 @@ execute() {
208208
}
209209

210210
# Fail with a clear message if the input contains any bell characters.
211-
if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then
212-
die "Compiler command line contains our separator ('${lsep}'). Cannot parse."
213-
fi
211+
case "$*" in
212+
*"$lsep"*)
213+
die "Compiler command line contains our separator ('${lsep}'). Cannot parse."
214+
;;
215+
esac
214216

215217
# ensure required variables are set
216218
for param in $params; do

test/run.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,19 @@ test_no_wrapper_environment() {
363363
esac
364364
}
365365

366+
test_separator_in_args() {
367+
wrapper_environment
368+
_out=$("$WRAPPER_DIR/cc" "hello$(printf '\a')world" 2>&1)
369+
_rc=$?
370+
if [ "$_rc" -eq 0 ]; then
371+
fail "cc with bell char in args unexpectedly exited 0"
372+
fi
373+
case "$_out" in
374+
*"Compiler command line contains our separator"*) ;;
375+
*) fail "expected 'Compiler command line contains our separator' in: $_out" ;;
376+
esac
377+
}
378+
366379
test_modes() {
367380
wrapper_environment
368381

@@ -1017,6 +1030,7 @@ expected: $_expected_LR"
10171030

10181031
all_tests='
10191032
test_no_wrapper_environment
1033+
test_separator_in_args
10201034
test_modes
10211035
test_expected_args
10221036
test_expected_args_with_flags

0 commit comments

Comments
 (0)