diff options
author | Ron Yorston <rmy@pobox.com> | 2022-04-07 11:41:52 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2022-04-07 11:41:52 +0100 |
commit | b34845ed2e1583bec6581b6881cc7d6c84454276 (patch) | |
tree | f1ecff71fa8f84e44f0b8794f0d2d33031f69dc8 /shell | |
parent | af41de68901d48753eb73491d54931a99d1a13b5 (diff) | |
parent | fc7868602ecf0d761a9a877141add4a9b6918d02 (diff) | |
download | busybox-w32-b34845ed2e1583bec6581b6881cc7d6c84454276.tar.gz busybox-w32-b34845ed2e1583bec6581b6881cc7d6c84454276.tar.bz2 busybox-w32-b34845ed2e1583bec6581b6881cc7d6c84454276.zip |
Merge branch 'busybox'
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ash.c | 16 | ||||
-rw-r--r-- | shell/ash_test/ash-vars/var_bash_repl_unterminated.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-vars/var_bash_repl_unterminated.tests | 2 | ||||
-rw-r--r-- | shell/hush_test/hush-vars/var_bash_repl_unterminated.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-vars/var_bash_repl_unterminated.tests | 2 |
5 files changed, 18 insertions, 4 deletions
diff --git a/shell/ash.c b/shell/ash.c index e8a1e853c..35aa3f6e6 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7163,9 +7163,7 @@ exptilde(char *startp, int flag) | |||
7163 | home = lookupvar("HOME"); | 7163 | home = lookupvar("HOME"); |
7164 | } else { | 7164 | } else { |
7165 | pw = getpwnam(name); | 7165 | pw = getpwnam(name); |
7166 | if (pw == NULL) | 7166 | home = pw ? pw->pw_dir : NULL; |
7167 | goto lose; | ||
7168 | home = pw->pw_dir; | ||
7169 | } | 7167 | } |
7170 | *p = c; | 7168 | *p = c; |
7171 | if (!home) | 7169 | if (!home) |
@@ -7724,6 +7722,10 @@ subevalvar(char *start, char *str, int strloc, | |||
7724 | *repl = '\0'; | 7722 | *repl = '\0'; |
7725 | break; | 7723 | break; |
7726 | } | 7724 | } |
7725 | if ((unsigned char)*repl == CTLENDVAR) { /* ${v/pattern} (no trailing /, no repl) */ | ||
7726 | repl = NULL; | ||
7727 | break; | ||
7728 | } | ||
7727 | /* Handle escaped slashes, e.g. "${v/\//_}" (they are CTLESC'ed by this point) */ | 7729 | /* Handle escaped slashes, e.g. "${v/\//_}" (they are CTLESC'ed by this point) */ |
7728 | if ((unsigned char)*repl == CTLESC && repl[1]) | 7730 | if ((unsigned char)*repl == CTLESC && repl[1]) |
7729 | repl++; | 7731 | repl++; |
@@ -7830,7 +7832,13 @@ subevalvar(char *start, char *str, int strloc, | |||
7830 | len = orig_len - pos; | 7832 | len = orig_len - pos; |
7831 | 7833 | ||
7832 | if (!quotes) { | 7834 | if (!quotes) { |
7833 | loc = mempcpy(startp, startp + pos, len); | 7835 | /* want: loc = mempcpy(startp, startp + pos, len) |
7836 | * but it does not allow overlapping arguments */ | ||
7837 | loc = startp; | ||
7838 | while (--len >= 0) { | ||
7839 | *loc = loc[pos]; | ||
7840 | loc++; | ||
7841 | } | ||
7834 | } else { | 7842 | } else { |
7835 | for (vstr = startp; pos != 0; pos--) { | 7843 | for (vstr = startp; pos != 0; pos--) { |
7836 | if ((unsigned char)*vstr == CTLESC) | 7844 | if ((unsigned char)*vstr == CTLESC) |
diff --git a/shell/ash_test/ash-vars/var_bash_repl_unterminated.right b/shell/ash_test/ash-vars/var_bash_repl_unterminated.right new file mode 100644 index 000000000..5bff3a6fa --- /dev/null +++ b/shell/ash_test/ash-vars/var_bash_repl_unterminated.right | |||
@@ -0,0 +1 @@ | |||
b/d | |||
diff --git a/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests b/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests new file mode 100755 index 000000000..c9513343d --- /dev/null +++ b/shell/ash_test/ash-vars/var_bash_repl_unterminated.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | a=b-c | ||
2 | echo ${a/-*}/d | ||
diff --git a/shell/hush_test/hush-vars/var_bash_repl_unterminated.right b/shell/hush_test/hush-vars/var_bash_repl_unterminated.right new file mode 100644 index 000000000..5bff3a6fa --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash_repl_unterminated.right | |||
@@ -0,0 +1 @@ | |||
b/d | |||
diff --git a/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests b/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests new file mode 100755 index 000000000..c9513343d --- /dev/null +++ b/shell/hush_test/hush-vars/var_bash_repl_unterminated.tests | |||
@@ -0,0 +1,2 @@ | |||
1 | a=b-c | ||
2 | echo ${a/-*}/d | ||