diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 16 |
1 files changed, 12 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) |