From 45dd87aac05ddf8bbfb110fde85ef875f3adfb65 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Fri, 21 Feb 2020 16:30:44 +0100 Subject: ash: expand: Ensure result is escaped in cvtnum Upstream commit: Date: Fri, 1 Jun 2018 18:25:29 +0800 expand: Ensure result is escaped in cvtnum The minus sign generated from arithmetic expansion is currently unquoted which causes anomalies when the result is used in where the quoting matters. This patch fixes it by explicitly calling memtodest on the result in cvtnum. Signed-off-by: Herbert Xu Signed-off-by: Denys Vlasenko --- shell/ash_test/ash-quoting/negative_arith.right | 2 ++ shell/ash_test/ash-quoting/negative_arith.tests | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 shell/ash_test/ash-quoting/negative_arith.right create mode 100755 shell/ash_test/ash-quoting/negative_arith.tests (limited to 'shell/ash_test') diff --git a/shell/ash_test/ash-quoting/negative_arith.right b/shell/ash_test/ash-quoting/negative_arith.right new file mode 100644 index 000000000..e7e51eee7 --- /dev/null +++ b/shell/ash_test/ash-quoting/negative_arith.right @@ -0,0 +1,2 @@ +tempfile0.tmp tempfile9.tmp +tempfile0.tmp tempfile1.tmp tempfile9.tmp diff --git a/shell/ash_test/ash-quoting/negative_arith.tests b/shell/ash_test/ash-quoting/negative_arith.tests new file mode 100755 index 000000000..8e47ca111 --- /dev/null +++ b/shell/ash_test/ash-quoting/negative_arith.tests @@ -0,0 +1,8 @@ +>tempfile0.tmp +>tempfile1.tmp +>tempfile9.tmp +# The [...] is interpreted as: "any of the chars 0, -, and 9" +echo tempfile[0"$((-9))"].tmp +# The [...] is [0-9], interpreted as: "any digit" +echo tempfile[0$((-9))].tmp +rm tempfile?.tmp -- cgit v1.2.3