diff options
author | Ron Yorston <rmy@pobox.com> | 2018-03-01 15:37:12 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-03-01 15:37:12 +0000 |
commit | 5b726f8a78c33e117c2a968739b1b4a6964905f8 (patch) | |
tree | af063c6bf3e99b7480c2fad2dffc2a76c09cb5e0 /shell/ash.c | |
parent | 5f8dac68690e92f0be220f8f8d9f797a2aedc806 (diff) | |
parent | cc222747ae7e264cbe9b1c8a9c253860275db8a9 (diff) | |
download | busybox-w32-5b726f8a78c33e117c2a968739b1b4a6964905f8.tar.gz busybox-w32-5b726f8a78c33e117c2a968739b1b4a6964905f8.tar.bz2 busybox-w32-5b726f8a78c33e117c2a968739b1b4a6964905f8.zip |
Merge branch 'busybox' into merge
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c index 88834f49a..394022df9 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -6517,12 +6517,12 @@ rmescapes(char *str, int flag, int *slash_position) | |||
6517 | if (*p == '*' | 6517 | if (*p == '*' |
6518 | || *p == '?' | 6518 | || *p == '?' |
6519 | || *p == '[' | 6519 | || *p == '[' |
6520 | || *p == '\\' /* case '\' in \\ ) echo ok;; *) echo WRONG;; esac */ | 6520 | || *p == '\\' /* case '\' in \\ ) echo ok;; *) echo WRONG;; esac */ |
6521 | || *p == ']' /* case ']' in [a\]] ) echo ok;; *) echo WRONG;; esac */ | 6521 | || *p == ']' /* case ']' in [a\]] ) echo ok;; *) echo WRONG;; esac */ |
6522 | || *p == '-' /* case '-' in [a\-c]) echo ok;; *) echo WRONG;; esac */ | 6522 | || *p == '-' /* case '-' in [a\-c]) echo ok;; *) echo WRONG;; esac */ |
6523 | || *p == '!' /* case '!' in [\!] ) echo ok;; *) echo WRONG;; esac */ | 6523 | || *p == '!' /* case '!' in [\!] ) echo ok;; *) echo WRONG;; esac */ |
6524 | /* Some libc support [^negate], that's why "^" also needs love */ | 6524 | /* Some libc support [^negate], that's why "^" also needs love */ |
6525 | || *p == '^' /* case '^' in [\^] ) echo ok;; *) echo WRONG;; esac */ | 6525 | || *p == '^' /* case '^' in [\^] ) echo ok;; *) echo WRONG;; esac */ |
6526 | ) { | 6526 | ) { |
6527 | *q++ = '\\'; | 6527 | *q++ = '\\'; |
6528 | } | 6528 | } |
@@ -12512,13 +12512,24 @@ readtoken1(int c, int syntax, char *eofmark, int striptabs) | |||
12512 | USTPUTC(CTLESC, out); | 12512 | USTPUTC(CTLESC, out); |
12513 | USTPUTC('\\', out); | 12513 | USTPUTC('\\', out); |
12514 | } | 12514 | } |
12515 | /* Backslash is retained if we are in "str" and next char isn't special */ | 12515 | /* Backslash is retained if we are in "str" |
12516 | * and next char isn't dquote-special. | ||
12517 | */ | ||
12516 | if (dblquote | 12518 | if (dblquote |
12517 | && c != '\\' | 12519 | && c != '\\' |
12518 | && c != '`' | 12520 | && c != '`' |
12519 | && c != '$' | 12521 | && c != '$' |
12520 | && (c != '"' || eofmark != NULL) | 12522 | && (c != '"' || eofmark != NULL) |
12521 | ) { | 12523 | ) { |
12524 | //dash survives not doing USTPUTC(CTLESC), but merely by chance: | ||
12525 | //Example: "\z" gets encoded as "\<CTLESC>z". | ||
12526 | //rmescapes() then emits "\", "\z", protecting z from globbing. | ||
12527 | //But it's wrong, should protect _both_ from globbing: | ||
12528 | //everything in double quotes is not globbed. | ||
12529 | //Unlike dash, we have a fix in rmescapes() which emits bare "z" | ||
12530 | //for "<CTLESC>z" since "z" is not glob-special (else unicode may break), | ||
12531 | //and glob would see "\z" and eat "\". Thus: | ||
12532 | USTPUTC(CTLESC, out); /* protect '\' from glob */ | ||
12522 | USTPUTC('\\', out); | 12533 | USTPUTC('\\', out); |
12523 | } | 12534 | } |
12524 | USTPUTC(CTLESC, out); | 12535 | USTPUTC(CTLESC, out); |