search for: smark

Displaying 20 results from an estimated 27 matches for "smark".

Did you mean: mark
2020 Mar 28
0
[klibc:update-dash] dash: eval: avoid leaking memory associated with redirections
...hanged, 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(union node...
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...e -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; - popstac...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...e -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; - popstac...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Handle embedded NULs correctly in printf
...y[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); + + len =...
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Handle embedded NULs correctly in printf
...y[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); + + len =...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...sr/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/histedi...
2019 Jan 25
0
[klibc:update-dash] input: Fix here-document redirection with vi/emacs on
...tions(+), 1 deletion(-) diff --git a/usr/dash/input.c b/usr/dash/input.c index 06c08d49..e53423c5 100644 --- a/usr/dash/input.c +++ b/usr/dash/input.c @@ -147,8 +147,12 @@ retry: static const char *rl_cp; static int el_len; - if (rl_cp == NULL) + if (rl_cp == NULL) { + struct stackmark smark; + pushstackmark(&smark, stackblocksize()); rl_cp = el_gets(el, &el_len); + popstackmark(&smark); + } if (rl_cp == NULL) nr = 0; else {
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...sr/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/histedi...
2020 Mar 28
0
[klibc:update-dash] dash: input: Fix here-document redirection with vi/emacs on
...tions(+), 1 deletion(-) diff --git a/usr/dash/input.c b/usr/dash/input.c index 06c08d49..e53423c5 100644 --- a/usr/dash/input.c +++ b/usr/dash/input.c @@ -147,8 +147,12 @@ retry: static const char *rl_cp; static int el_len; - if (rl_cp == NULL) + if (rl_cp == NULL) { + struct stackmark smark; + pushstackmark(&smark, stackblocksize()); rl_cp = el_gets(el, &el_len); + popstackmark(&smark); + } if (rl_cp == NULL) nr = 0; else {
2019 Jan 25
0
[klibc:update-dash] builtin: Fix echo performance regression
...letions(-) diff --git a/usr/dash/bltin/printf.c b/usr/dash/bltin/printf.c index 1f1fbde7..fe055fd2 100644 --- a/usr/dash/bltin/printf.c +++ b/usr/dash/bltin/printf.c @@ -100,20 +100,25 @@ static int print_escape_str(const char *f, int *param, int *array, char *s) int total; setstackmark(&smark); - done = conv_escape_str(s, &p); - q = stackblock(); - len = p - q; + done = conv_escape_str(s, &q); + p = stackblock(); + len = q - p; + total = len - 1; + + if (f[1] == 's') + goto easy; - p = makestrspace(len, p); - memset(p, 'X', len - 1); - p[len - 1] = 0; + p = ma...
2019 Jan 25
0
[klibc:update-dash] eval: Restore input files in evalcommand
...sr/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 = CMDBUILTIN...
2020 Mar 28
0
[klibc:update-dash] dash: builtin: Fix echo performance regression
...letions(-) diff --git a/usr/dash/bltin/printf.c b/usr/dash/bltin/printf.c index 1f1fbde7..fe055fd2 100644 --- a/usr/dash/bltin/printf.c +++ b/usr/dash/bltin/printf.c @@ -100,20 +100,25 @@ static int print_escape_str(const char *f, int *param, int *array, char *s) int total; setstackmark(&smark); - done = conv_escape_str(s, &p); - q = stackblock(); - len = p - q; + done = conv_escape_str(s, &q); + p = stackblock(); + len = q - p; + total = len - 1; + + if (f[1] == 's') + goto easy; - p = makestrspace(len, p); - memset(p, 'X', len - 1); - p[len - 1] = 0; + p = ma...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Restore input files in evalcommand
...sr/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 = CMDBUILTIN...
2019 Jan 25
0
[klibc:update-dash] eval: Fix exit status when calling eval/dot with no commands
...6ec0ef 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -172,7 +172,8 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); - status = exitstatus; + if (n) + status = exitstatus; popstackmark(&smark); if (evalskip) break; diff --git a/usr/dash/main.c b/usr/dash/main.c index bedb6635..497ac160 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -228,7 +228,8 @@ cmdloop(int top) job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; evaltree(n, 0); - status = exitstatus; +...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Fix exit status when calling eval/dot with no commands
...80d1d2 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -172,7 +172,8 @@ evalstring(char *s, int flags) status = 0; while ((n = parsecmd(0)) != NEOF) { evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT)); - status = exitstatus; + if (n) + status = exitstatus; popstackmark(&smark); if (evalskip) break; diff --git a/usr/dash/main.c b/usr/dash/main.c index bedb6635..497ac160 100644 --- a/usr/dash/main.c +++ b/usr/dash/main.c @@ -228,7 +228,8 @@ cmdloop(int top) job_warning = (job_warning == 2) ? 1 : 0; numeof = 0; evaltree(n, 0); - status = exitstatus; +...
2020 Mar 28
0
[klibc:update-dash] dash: expand: Do not reprocess data when expanding words
...ark(&sm, endoff); + result = arith(start); popstackmark(&sm); len = cvtnum(result); if (likely(!(flag & EXP_QUOTED))) recordregion(begoff, begoff + len, 0); + +out: + return p; } @@ -512,6 +488,9 @@ expbackq(union node *cmd, int flag) int startloc; struct stackmark smark; + if (flag & EXP_DISCARD) + goto out; + INTOFF; startloc = expdest - (char *)stackblock(); pushstackmark(&smark, startloc); @@ -556,6 +535,9 @@ read: (dest - (char *)stackblock()) - startloc, (dest - (char *)stackblock()) - startloc, stackblock() + startloc)); + +out: + a...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Move common skipcount logic into skiploop
...; - if (evalskip) { - if (evalskip == SKIPCONT && --skipcount <= 0) { - evalskip = 0; - continue; - } - if (evalskip == SKIPBREAK && --skipcount <= 0) - evalskip = 0; + if (skiploop() & ~SKIPCONT) break; - } } loopnest--; -out: popstackmark(&smark); }
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Move common skipcount logic into skiploop
...; - if (evalskip) { - if (evalskip == SKIPCONT && --skipcount <= 0) { - evalskip = 0; - continue; - } - if (evalskip == SKIPBREAK && --skipcount <= 0) - evalskip = 0; + if (skiploop() & ~SKIPCONT) break; - } } loopnest--; -out: popstackmark(&smark); }
2020 Mar 28
0
[klibc:update-dash] dash: eval: Reset handler when entering a subshell
...hort 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) e...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Only restore exit status on exit/return
...us = savestatus; + if (exception == EXEXIT || evalskip == SKIPFUNCDEF) + exitstatus = savestatus; savestatus = -1; } + evalskip = 0; + loopnest = 0; } #endif @@ -318,7 +319,7 @@ out: if (flags & EV_EXIT) { exexit: - exraise(EXEXIT); + exraise(EXEND); } popstackmark(&smark); diff --git a/usr/dash/exec.c b/usr/dash/exec.c index 9d0215a6..87354d49 100644 --- a/usr/dash/exec.c +++ b/usr/dash/exec.c @@ -143,7 +143,7 @@ shellexec(char **argv, const char *path, int idx) exitstatus = exerrno; TRACE(("shellexec failed for %s, errno %d, suppressint %d\n", arg...