search for: dotrap

Displaying 16 results from an estimated 16 matches for "dotrap".

Did you mean: notrap
2019 Jan 25
0
[klibc:update-dash] [TRAP] Make sure evalskip is zero before running traps
...b0fe674774173e57 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 2 Oct 2014 19:49:48 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [TRAP] Make sure evalskip is zero before running traps As it is if dotrap is called with evalskip set to a nonzero value, it'll try to execute any set traps. The result is that the first command in the first set trap will be executed while the rest of the trap will be silently ignored due to evalskip. This is highly counterintuitive, even though both bash and ksh e...
2020 Mar 28
0
[klibc:update-dash] dash: [TRAP] Make sure evalskip is zero before running traps
...ana.org.au> AuthorDate: Thu, 2 Oct 2014 19:49:48 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [TRAP] Make sure evalskip is zero before running traps [ dash commit d28c13e7119a605ef152a4310e9415dc7ae9b8f3 ] As it is if dotrap is called with evalskip set to a nonzero value, it'll try to execute any set traps. The result is that the first command in the first set trap will be executed while the rest of the trap will be silently ignored due to evalskip. This is highly counterintuitive, even though both bash and ksh e...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...git;a=commit;h=91912a4156a5e5e51cc54a3c69ce0b3b87df7720 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 2 Oct 2014 08:26:06 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Fri, 25 Jan 2019 02:57:21 +0000 [klibc] [EVAL] Fix use-after-free in dotrap/evalstring The function dotrap calls evalstring using the stored trap string. If evalstring then unsets that exact trap string then we will end up using freed memory. This patch fixes it by making evalstring always duplicate the string before using it. Signed-off-by: Herbert Xu <herbert at go...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...commit;h=097a6e92dd6aea6d1e1e872c3aa02d677a004a88 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 2 Oct 2014 08:26:06 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: [EVAL] Fix use-after-free in dotrap/evalstring [ dash commit 6c3f73bc536082fec38bd36e6c8a121033c68835 ] The function dotrap calls evalstring using the stored trap string. If evalstring then unsets that exact trap string then we will end up using freed memory. This patch fixes it by making evalstring always duplicate the string bef...
2020 Mar 28
0
[klibc:update-dash] dash: eval: make traps work when "set -e" is enabled
...#!/bin/dash set -e trap 'ret=$?; echo "EXIT: $ret"' EXIT trap 'exit 2' HUP INT QUIT PIPE TERM read variable By pressing Ctrl-C one would expect the EXIT trap to be called, as it is the case with other shells (bash, zsh), but dash does not do it. By calling dotrap() before jumping to the exit path when checkexit is not zero, dash behaves like other shells. Signed-off-by: Antonio Ospite <ao2 at ao2.it> Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/eval.c | 4 +...
2019 Jan 25
0
[klibc:update-dash] trap: Globally rename pendingsigs to pending_sig
...ingsigs; +volatile sig_atomic_t pending_sig; /* received SIGCHLD */ int gotsigchld; @@ -290,7 +290,7 @@ onsig(int signo) } gotsig[signo - 1] = 1; - pendingsigs = signo; + pending_sig = signo; if (signo == SIGINT && !trap[SIGINT]) { if (!suppressint) @@ -313,7 +313,7 @@ void dotrap(void) int i; int status, last_status; - if (!pendingsigs) + if (!pending_sig) return; status = savestatus; @@ -322,7 +322,7 @@ void dotrap(void) status = exitstatus; savestatus = status; } - pendingsigs = 0; + pending_sig = 0; barrier(); for (i = 0, q = gotsig; i < NSI...
2020 Mar 28
0
[klibc:update-dash] dash: trap: Globally rename pendingsigs to pending_sig
...ingsigs; +volatile sig_atomic_t pending_sig; /* received SIGCHLD */ int gotsigchld; @@ -290,7 +290,7 @@ onsig(int signo) } gotsig[signo - 1] = 1; - pendingsigs = signo; + pending_sig = signo; if (signo == SIGINT && !trap[SIGINT]) { if (!suppressint) @@ -313,7 +313,7 @@ void dotrap(void) int i; int status, last_status; - if (!pendingsigs) + if (!pending_sig) return; status = savestatus; @@ -322,7 +322,7 @@ void dotrap(void) status = exitstatus; savestatus = status; } - pendingsigs = 0; + pending_sig = 0; barrier(); for (i = 0, q = gotsig; i < NSI...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Exit without arguments in a trap should use status outside traps
...tatus = number(argv[1]); + + exitstatus = status; + if (savestatus >= 0) + savestatus = status; + } + exraise(EXEXIT); /* NOTREACHED */ } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 3ff45318..7dd8342f 100644 --- a/usr/dash/trap.c +++ b/usr/dash/trap.c @@ -313,12 +313,17 @@ void dotrap(void) char *p; char *q; int i; - int savestatus; + int status, last_status; if (!pendingsigs) return; - savestatus = exitstatus; + status = savestatus; + last_status = status; + if (likely(status < 0)) { + status = exitstatus; + savestatus = status; + } pendingsigs = 0; barr...
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Exit without arguments in a trap should use status outside traps
...tatus = number(argv[1]); + + exitstatus = status; + if (savestatus >= 0) + savestatus = status; + } + exraise(EXEXIT); /* NOTREACHED */ } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 3ff45318..7dd8342f 100644 --- a/usr/dash/trap.c +++ b/usr/dash/trap.c @@ -313,12 +313,17 @@ void dotrap(void) char *p; char *q; int i; - int savestatus; + int status, last_status; if (!pendingsigs) return; - savestatus = exitstatus; + status = savestatus; + last_status = status; + if (likely(status < 0)) { + status = exitstatus; + savestatus = status; + } pendingsigs = 0; barr...
2004 Oct 18
0
Error building ash: trap.c:398: error: conflicting types for 'onsig'
...[all] Error 2 This fixes it for me: --- ash/trap.h.old 2004-10-19 00:04:21.021269720 +0000 +++ ash/trap.h 2004-10-19 00:04:37.218807320 +0000 @@ -40,7 +40,7 @@ void clear_traps(int); long setsignal(int, int); void ignoresig(int, int); -void onsig(int); +__cdecl void onsig(int); void dotrap(void); void setinteractive(int); void exitshell(int) __attribute__((__noreturn__)); Daniel Thaler
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Return without arguments in a trap should use status outside traps
...cmdloop(int top) skip = evalskip; if (skip) { - evalskip &= ~SKIPFUNC; + evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); break; } } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 7dd8342f..b8470437 100644 --- a/usr/dash/trap.c +++ b/usr/dash/trap.c @@ -342,7 +342,8 @@ void dotrap(void) if (!p) continue; evalstring(p, 0); - exitstatus = status; + if (evalskip != SKIPFUNC) + exitstatus = status; } savestatus = last_status;
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Return without arguments in a trap should use status outside traps
...cmdloop(int top) skip = evalskip; if (skip) { - evalskip &= ~SKIPFUNC; + evalskip &= ~(SKIPFUNC | SKIPFUNCDEF); break; } } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 7dd8342f..b8470437 100644 --- a/usr/dash/trap.c +++ b/usr/dash/trap.c @@ -342,7 +342,8 @@ void dotrap(void) if (!p) continue; evalstring(p, 0); - exitstatus = status; + if (evalskip != SKIPFUNC) + exitstatus = status; } savestatus = last_status;
2020 Mar 28
0
[klibc:update-dash] dash: eval: Add vfork support
...t_t *oldmask) +{ + sigset_t mask; + + sigfillset(&mask); + sigprocmask(SIG_SETMASK, &mask, oldmask); +} + /* * Human-readable signal name */ diff --git a/usr/dash/trap.h b/usr/dash/trap.h index a095b0e1..bbff1842 100644 --- a/usr/dash/trap.h +++ b/usr/dash/trap.h @@ -50,6 +50,7 @@ void dotrap(void); void setinteractive(int); void exitshell(void) __attribute__((__noreturn__)); int decode_signal(const char *, int); +void sigblockall(sigset_t *oldmask); const char *signal_name(int); static inline int have_traps(void)
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...art) { n = n->nif.elsepart; goto evaln; } - goto success; + status = 0; + goto setstatus; case NDEFUN: defun(n); -success: - status = 0; setstatus: exitstatus = status; break; } out: - if (checkexit & exitstatus) + if (checkexit & status) goto exexit; dotrap(); @@ -323,6 +315,8 @@ out: exexit: exraise(EXEXIT); } + + return exitstatus; } @@ -363,7 +357,7 @@ static int skiploop(void) } -STATIC void +STATIC int evalloop(union node *n, int flags) { int skip; @@ -375,33 +369,34 @@ evalloop(union node *n, int flags) do { int i; -...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...art) { n = n->nif.elsepart; goto evaln; } - goto success; + status = 0; + goto setstatus; case NDEFUN: defun(n); -success: - status = 0; setstatus: exitstatus = status; break; } out: - if (checkexit & exitstatus) + if (checkexit & status) goto exexit; dotrap(); @@ -323,6 +315,8 @@ out: exexit: exraise(EXEXIT); } + + return exitstatus; } @@ -363,7 +357,7 @@ static int skiploop(void) } -STATIC void +STATIC int evalloop(union node *n, int flags) { int skip; @@ -375,33 +369,34 @@ evalloop(union node *n, int flags) do { int i; -...
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...if (skip) + if (evalskip) break; } popfile(); - skip &= mask; - evalskip = skip; - return skip; + evalskip &= mask; + return status; } diff --git a/usr/dash/trap.c b/usr/dash/trap.c index 51e1d56..dc27224 100644 --- a/usr/dash/trap.c +++ b/usr/dash/trap.c @@ -294,7 +294,6 @@ dotrap(void) char *q; int i; int savestatus; - int skip = 0; savestatus = exitstatus; pendingsigs = 0; @@ -308,13 +307,13 @@ dotrap(void) p = trap[i + 1]; if (!p) continue; - skip = evalstring(p, SKIPEVAL); + evalstring(p, SKIPEVAL); exitstatus = savestatus; - if (skip) - bre...