From 05c10507e983781e5b0b2c85eec0362929fe6941 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Fri, 25 Dec 2009 15:29:18 +0000 Subject: [PATCH] sh: Do not consider a tilde-prefix with expansions in it. That is, do not do tilde expansion if any of the CTL* bytes (\201-\210), not only CTLESC and CTLQUOTEMARK, are encountered. Such an expansion would look up a user name with sh's internal representation. The parser does not currently distinguish between backslashed and unbackslashed \201-\210, so tilde expansion of user names with these bytes in them is not so easy to fix. --- bin/sh/expand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/sh/expand.c b/bin/sh/expand.c index db86dac6669a..5faf8074f361 100644 --- a/bin/sh/expand.c +++ b/bin/sh/expand.c @@ -271,8 +271,13 @@ exptilde(char *p, int flag) while ((c = *p) != '\0') { switch(c) { - case CTLESC: - return (startp); + case CTLESC: /* This means CTL* are always considered quoted. */ + case CTLVAR: + case CTLENDVAR: + case CTLBACKQ: + case CTLBACKQ | CTLQUOTE: + case CTLARI: + case CTLENDARI: case CTLQUOTEMARK: return (startp); case ':':