From d0db975a9f399140ddb7dacdfffaf098df3e249b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 12 Jun 2010 15:51:29 +0200 Subject: post-1.16.1 fixes Signed-off-by: Denys Vlasenko --- shell/ash.c | 6 +++++- shell/hush.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'shell') diff --git a/shell/ash.c b/shell/ash.c index 34f70ecfc..e018e877b 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -5059,7 +5059,7 @@ static int is_hidden_fd(struct redirtab *rp, int fd) return 0; pf = g_parsefile; while (pf) { - if (fd == pf->fd) { + if (pf->fd > 0 && fd == pf->fd) { return 1; } pf = pf->prev; @@ -5424,7 +5424,11 @@ rmescapes(char *str, int flag) size_t fulllen = len + strlen(p) + 1; if (flag & RMESCAPE_GROW) { + int strloc = str - (char *)stackblock(); r = makestrspace(fulllen, expdest); + /* p and str may be invalidated by makestrspace */ + str = (char *)stackblock() + strloc; + p = str + len; } else if (flag & RMESCAPE_HEAP) { r = ckmalloc(fulllen); } else { diff --git a/shell/hush.c b/shell/hush.c index 2aeb8e440..78f0f7940 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -6944,7 +6944,7 @@ int hush_main(int argc, char **argv) /* -c 'script' (no params): prevent empty $0 */ G.global_argv--; /* points to argv[i] of 'script' */ G.global_argv[0] = argv[0]; - G.global_argc--; + G.global_argc++; } /* else -c 'script' ARG0 [ARG1...]: $0 is ARG0 */ init_sigmasks(); parse_and_run_string(optarg); -- cgit v1.2.3-55-g6feb