search for: stackmark

Displaying 17 results from an estimated 17 matches for "stackmark".

Did you mean: stackmap
2020 Mar 28
0
[klibc:update-dash] dash: memalloc: Avoid looping in growstackto
...g.uk> --- usr/dash/memalloc.c | 16 ++++++++-------- usr/dash/memalloc.h | 1 - 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/usr/dash/memalloc.c b/usr/dash/memalloc.c index 9d1de74a..60637da1 100644 --- a/usr/dash/memalloc.c +++ b/usr/dash/memalloc.c @@ -201,16 +201,16 @@ popstackmark(struct stackmark *mark) * part of the block that has been used. */ -void -growstackblock(void) +static void growstackblock(size_t min) { size_t newlen; newlen = stacknleft * 2; if (newlen < stacknleft) sh_error("Out of space"); - if (newlen < 128) - newlen += 128;...
2020 Mar 28
0
[klibc:update-dash] dash: eval: avoid leaking memory associated with redirections
...1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index 5074aa94..bba0e7f8 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -200,8 +200,12 @@ evaltree(union node *n, int flags) { int checkexit = 0; int (*evalfn)(union node *, int); + struct stackmark smark; unsigned isor; int status = 0; + + setstackmark(&smark); + if (n == NULL) { TRACE(("evaltree(NULL) called\n")); goto out; @@ -317,6 +321,8 @@ exexit: exraise(EXEXIT); } + popstackmark(&smark); + return exitstatus; } @@ -396,14 +402,12 @@ evalfor(unio...
2020 Mar 28
0
[klibc:update-dash] dash: memalloc: Add growstackto helper
...>= newlen) - break; - growstackblock(); - } - return stackblock() + len; + return growstackto(len + newlen) + len; } char * diff --git a/usr/dash/memalloc.h b/usr/dash/memalloc.h index 4b5be46c..b348d9cc 100644 --- a/usr/dash/memalloc.h +++ b/usr/dash/memalloc.h @@ -57,6 +57,7 @@ void setstackmark(struct stackmark *); void popstackmark(struct stackmark *); void growstackblock(void); void *growstackstr(void); +char *growstackto(size_t len); char *makestrspace(size_t, char *); char *stnputs(const char *, size_t, char *); char *stputs(const char *, char *); diff --git a/usr/dash/parser.c...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Handle embedded NULs correctly in printf
...p, f, array[0], array[1], func); \ + break; \ + case sizeof(*param): \ + ret = xasprintf(sp, f, array[0], func); \ + break; \ + case 0: \ + ret = xasprintf(sp, f, func); \ + break; \ + } \ + ret; \ +}) + + +static int print_escape_str(const char *f, int *param, int *array, char *s) +{ + struct stackmark smark; + char *p, *q; + int done; + int len; + int total; + + setstackmark(&smark); + done = conv_escape_str(s, &p); + q = stackblock(); + len = p - q; + + p = makestrspace(len, p); + memset(p, 'X', len - 1); + p[len - 1] = 0; + + q = stackblock(); + total = ASPF(&p, f, p); + +...
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Handle embedded NULs correctly in printf
...p, f, array[0], array[1], func); \ + break; \ + case sizeof(*param): \ + ret = xasprintf(sp, f, array[0], func); \ + break; \ + case 0: \ + ret = xasprintf(sp, f, func); \ + break; \ + } \ + ret; \ +}) + + +static int print_escape_str(const char *f, int *param, int *array, char *s) +{ + struct stackmark smark; + char *p, *q; + int done; + int len; + int total; + + setstackmark(&smark); + done = conv_escape_str(s, &p); + q = stackblock(); + len = p - q; + + p = makestrspace(len, p); + memset(p, 'X', len - 1); + p[len - 1] = 0; + + q = stackblock(); + total = ASPF(&p, f, p); + +...
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...ckcmd *); #else -STATIC void evalcommand(union node *, int); +STATIC int evalcommand(union node *, int); #endif STATIC int evalbltin(const struct builtincmd *, int, char **, int); STATIC int evalfun(struct funcnode *, int, char **, int); @@ -170,11 +170,13 @@ evalstring(char *s, int flags) setstackmark(&smark); status = 0; - while ((n = parsecmd(0)) != NEOF) { - evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); + for (; (n = parsecmd(0)) != NEOF; popstackmark(&smark)) { + int i; + + i = evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); if (n) - status = exitstatus;...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...ckcmd *); #else -STATIC void evalcommand(union node *, int); +STATIC int evalcommand(union node *, int); #endif STATIC int evalbltin(const struct builtincmd *, int, char **, int); STATIC int evalfun(struct funcnode *, int, char **, int); @@ -170,11 +170,13 @@ evalstring(char *s, int flags) setstackmark(&smark); status = 0; - while ((n = parsecmd(0)) != NEOF) { - evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); + for (; (n = parsecmd(0)) != NEOF; popstackmark(&smark)) { + int i; + + i = evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); if (n) - status = exitstatus;...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...t; --- usr/dash/eval.c | 3 +++ usr/dash/histedit.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index da39136d..755136e2 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -160,6 +160,7 @@ evalstring(char *s, int flags) struct stackmark smark; int status; + s = sstrdup(s); setinputstring(s); setstackmark(&smark); @@ -171,7 +172,9 @@ evalstring(char *s, int flags) if (evalskip) break; } + popstackmark(&smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/h...
2019 Jan 25
0
[klibc:update-dash] input: Fix here-document redirection with vi/emacs on
...utput to see. Nice find. The problem is that getprompt() is implicitly called by el_gets(). This messes with the memory used by the parser to store the here-document's contents. In the non-emacs/vi case, the prompt is explicitly written by setprompt(), which wraps the getprompt() call in a pushstackmark()/popstackmark() pair to restore the state so that parsing can continue. But when getprompt() is called by el_gets(), it knows nothing about this. The whole call to el_gets() can be surrounded by another pushstackmark()/popstackmark() pair to solve the problem, as attached. Cheers, Harald van Dij...
2019 Jan 25
0
[klibc:update-dash] eval: Restore input files in evalcommand
...--git a/usr/dash/eval.c b/usr/dash/eval.c index 811c28a4..5fd1c7c1 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -694,6 +694,7 @@ evalcommand(union node *cmd, int flags) #endif { struct localvar_list *localvar_stop; + struct parsefile *file_stop; struct redirtab *redir_stop; struct stackmark smark; union node *argp; @@ -722,6 +723,7 @@ evalcommand(union node *cmd, int flags) TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); setstackmark(&smark); localvar_stop = pushlocalvars(); + file_stop = parsefile; back_exitstatus = 0; cmdentry.cmdtype = CMDB...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...t; --- usr/dash/eval.c | 3 +++ usr/dash/histedit.c | 3 +-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/usr/dash/eval.c b/usr/dash/eval.c index e6f6cd5c..adf05fde 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -160,6 +160,7 @@ evalstring(char *s, int flags) struct stackmark smark; int status; + s = sstrdup(s); setinputstring(s); setstackmark(&smark); @@ -171,7 +172,9 @@ evalstring(char *s, int flags) if (evalskip) break; } + popstackmark(&smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/h...
2020 Mar 28
0
[klibc:update-dash] dash: input: Fix here-document redirection with vi/emacs on
...utput to see. Nice find. The problem is that getprompt() is implicitly called by el_gets(). This messes with the memory used by the parser to store the here-document's contents. In the non-emacs/vi case, the prompt is explicitly written by setprompt(), which wraps the getprompt() call in a pushstackmark()/popstackmark() pair to restore the state so that parsing can continue. But when getprompt() is called by el_gets(), it knows nothing about this. The whole call to el_gets() can be surrounded by another pushstackmark()/popstackmark() pair to solve the problem, as attached. Cheers, Harald van Dij...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Restore input files in evalcommand
...--git a/usr/dash/eval.c b/usr/dash/eval.c index 26055493..e28e56cb 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -694,6 +694,7 @@ evalcommand(union node *cmd, int flags) #endif { struct localvar_list *localvar_stop; + struct parsefile *file_stop; struct redirtab *redir_stop; struct stackmark smark; union node *argp; @@ -722,6 +723,7 @@ evalcommand(union node *cmd, int flags) TRACE(("evalcommand(0x%lx, %d) called\n", (long)cmd, flags)); setstackmark(&smark); localvar_stop = pushlocalvars(); + file_stop = parsefile; back_exitstatus = 0; cmdentry.cmdtype = CMDB...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Do not reprocess data when expanding words
...eturn (startp); } @@ -437,63 +433,43 @@ removerecordregions(int endoff) * Expand arithmetic expression. Backup to start of expression, * evaluate, place result in (backed up) result, adjust string position. */ -void -expari(int flag) +static char *expari(char *start, int flag) { struct stackmark sm; - char *p, *start; int begoff; + int endoff; int len; intmax_t result; + char *p; - /* ifsfree(); */ - - /* - * This routine is slightly over-complicated for - * efficiency. Next we scan backwards looking for the - * start of arithmetic. - */ - start = stackblock(); - p = expdest;...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Reset handler when entering a subshell
..._errno; short profile_buf[16384]; extern int etext(); #endif +static struct jmploc main_handler; STATIC void read_profile(const char *); STATIC char *find_dot_file(char *); @@ -90,7 +91,6 @@ main(int argc, char **argv) { char *shinit; volatile int state; - struct jmploc jmploc; struct stackmark smark; int login; @@ -102,7 +102,7 @@ main(int argc, char **argv) monitor(4, etext, profile_buf, sizeof profile_buf, 50); #endif state = 0; - if (unlikely(setjmp(jmploc.loc))) { + if (unlikely(setjmp(main_handler.loc))) { int e; int s; @@ -137,7 +137,7 @@ main(int argc, char **argv...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Merge syntax/quotes in memtodest with flags
...o lose; *p = c; - strtodest(home, SQSYNTAX, quotes); + strtodest(home, flag | EXP_QUOTED); return (p); lose: *p = c; @@ -513,7 +510,6 @@ expbackq(union node *cmd, int flag) char *p; char *dest; int startloc; - char const *syntax = flag & EXP_QUOTED ? DQSYNTAX : BASESYNTAX; struct stackmark smark; INTOFF; @@ -527,7 +523,7 @@ expbackq(union node *cmd, int flag) if (i == 0) goto read; for (;;) { - memtodest(p, i, syntax, flag & QUOTES_ESC); + memtodest(p, i, flag); read: if (in.fd < 0) break; @@ -835,8 +831,9 @@ end: * Put a string on the stack. */ -STA...
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...p = grabstackstr(concat); } - evalstring(p, ~SKIPEVAL); - + return evalstring(p, ~SKIPEVAL); } - return exitstatus; + return 0; } @@ -166,24 +165,23 @@ evalstring(char *s, int mask) { union node *n; struct stackmark smark; - int skip; + int status; setinputstring(s); setstackmark(&smark); - skip = 0; + status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, 0); + status = exitstatus; popstackmark(&smark); - skip = evalskip; - if (skip) + if (evalskip) break; } popfile();...