Skip to content
Snippets Groups Projects
Commit 2a7aa74e authored by Sören Tempel's avatar Sören Tempel
Browse files

main/busybox: backport yet another ash pattern substitution fix

parent aa8ac2e8
No related branches found
No related tags found
No related merge requests found
From c5a1be25ba6dd705382ce6c25d96a32f79974c04 Mon Sep 17 00:00:00 2001
From: Denys Vlasenko <vda.linux@googlemail.com>
Date: Mon, 26 Feb 2024 16:26:15 +0100
Subject: [PATCH] ash: fix handling of single-quoted strings in pattern
substitution
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
function old new delta
subevalvar 1576 1588 +12
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Signed-off-by: Sören Tempel <soeren+git@soeren-tempel.net>
---
shell/ash.c | 5 +++++
shell/ash_test/ash-quoting/dollar_repl_bash2.right | 4 ++++
shell/ash_test/ash-quoting/dollar_repl_bash2.tests | 8 ++++++++
shell/hush_test/hush-quoting/dollar_repl_bash2.right | 4 ++++
shell/hush_test/hush-quoting/dollar_repl_bash2.tests | 8 ++++++++
5 files changed, 29 insertions(+)
create mode 100644 shell/ash_test/ash-quoting/dollar_repl_bash2.right
create mode 100755 shell/ash_test/ash-quoting/dollar_repl_bash2.tests
create mode 100644 shell/hush_test/hush-quoting/dollar_repl_bash2.right
create mode 100755 shell/hush_test/hush-quoting/dollar_repl_bash2.tests
diff --git a/shell/ash.c b/shell/ash.c
index 771fc8bf9..4ca4c6c56 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7073,6 +7073,11 @@ subevalvar(char *start, char *str, int strloc,
repl = NULL;
break;
}
+ /* Skip over quoted 'str'. Example: ${var/'/'} - second / is not a separator */
+ if ((unsigned char)*repl == CTLQUOTEMARK) {
+ while ((unsigned char)*++repl != CTLQUOTEMARK)
+ continue;
+ }
if (*repl == '/') {
*repl = '\0';
break;
diff --git a/shell/ash_test/ash-quoting/dollar_repl_bash2.right b/shell/ash_test/ash-quoting/dollar_repl_bash2.right
new file mode 100644
index 000000000..e3fcd5807
--- /dev/null
+++ b/shell/ash_test/ash-quoting/dollar_repl_bash2.right
@@ -0,0 +1,4 @@
+axxb
+axxb
+axxb
+axxb
diff --git a/shell/ash_test/ash-quoting/dollar_repl_bash2.tests b/shell/ash_test/ash-quoting/dollar_repl_bash2.tests
new file mode 100755
index 000000000..45c7a10e2
--- /dev/null
+++ b/shell/ash_test/ash-quoting/dollar_repl_bash2.tests
@@ -0,0 +1,8 @@
+v="x/x"
+# The second / is quoted, should not be treated as separator
+echo a${v/'/'}b
+# The second / is escaped, should not be treated as separator
+echo a${v/\/}b
+
+echo "a${v/'/'}b"
+echo "a${v/\/}b"
diff --git a/shell/hush_test/hush-quoting/dollar_repl_bash2.right b/shell/hush_test/hush-quoting/dollar_repl_bash2.right
new file mode 100644
index 000000000..e3fcd5807
--- /dev/null
+++ b/shell/hush_test/hush-quoting/dollar_repl_bash2.right
@@ -0,0 +1,4 @@
+axxb
+axxb
+axxb
+axxb
diff --git a/shell/hush_test/hush-quoting/dollar_repl_bash2.tests b/shell/hush_test/hush-quoting/dollar_repl_bash2.tests
new file mode 100755
index 000000000..45c7a10e2
--- /dev/null
+++ b/shell/hush_test/hush-quoting/dollar_repl_bash2.tests
@@ -0,0 +1,8 @@
+v="x/x"
+# The second / is quoted, should not be treated as separator
+echo a${v/'/'}b
+# The second / is escaped, should not be treated as separator
+echo a${v/\/}b
+
+echo "a${v/'/'}b"
+echo "a${v/\/}b"
......@@ -5,7 +5,7 @@
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=busybox
pkgver=1.36.1
pkgrel=19
pkgrel=20
pkgdesc="Size optimized toolbox of many common UNIX utilities"
url="https://busybox.net/"
arch="all"
......@@ -81,6 +81,7 @@ source="https://busybox.net/downloads/busybox-$pkgver.tar.bz2
0032-install-Fix-chown-resetting-suid-sgid-bits-from-chmo.patch
0033-find-fix-xdev-depth-and-delete.patch
0034-udhcp-Avoid-leaking-uninitialized-stale-data.patch
0035-ash-fix-handling-of-single-quoted-strings-in-pattern.patch
acpid.logrotate
busyboxconfig
......@@ -425,6 +426,7 @@ f12c2d5cdb3a6b81f109029b22a6b1064a32aee5a2c5ff0b0a290f9090d5eda060b35f62f2faba33
0d71e70ed3de87f11a8a94e00b26e74d437b7ae96292507f1d42c850f461a4ea9de28d19f4fbfee087042fa6b14362e7046618d5dd0833cfac96954002766a60 0032-install-Fix-chown-resetting-suid-sgid-bits-from-chmo.patch
724cfa5dd9eba1b4de448d2e29762821492435e1687d5345b000309f8b38a20f735d57ee6e44c476add94ccb42dd01157d95b75c2da191d04e924dd6635992de 0033-find-fix-xdev-depth-and-delete.patch
7e929e71b398502f91b429b29c43a93ac05d2281cd8b021a5398f4ecaedd8061c048833ecc8f012adade2a197de85f18cb12f9513867222ea17f0acb9e7d9161 0034-udhcp-Avoid-leaking-uninitialized-stale-data.patch
5ae02b7e3d8f040bdf78f2465f918cca1683898574d018dfde0b6ab9270e39f58b6adad3936537ea9eab52fe9b78bf05443d99e1bfd72fa1466a0330bc640d77 0035-ash-fix-handling-of-single-quoted-strings-in-pattern.patch
aa93095e20de88730f526c6f463cef711b290b9582cdbd8c1ba2bd290019150cbeaa7007c2e15f0362d5b9315dd63f60511878f0ea05e893f4fdfb4a54af3fb1 acpid.logrotate
076f13b9d85ebf23aff8c0a2f313d3ca05f4d1c0d3ed06b0bc274d41deda3bd4808a8381f7c0411e8188b67315cc7ac8dced1b4473cda3c247773dbce2b71f55 busyboxconfig
cfd96023125ca27c6eddb13af490a36e5e7d2fcfd0847363e48f1fa5ce237e93e6a9fe4577feeb35291d79d6240ae5e6a518b9258966e0fac27e30a43172b792 busyboxconfig-extras
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment