Displaying 18 results from an estimated 18 matches for "evalstr".
Did you mean:
dialstr
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...ommit;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 gondor.apa...
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...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
before usin...
2008 Jul 11
1
Subsetting an array by a vector of dimensions
Hi
Is it possible to subset an n-dimensional array by a vector of n dimensions? E.g. assume I have
> x <- array(1:24, dim=2:4)
> x[1,1,2]
[1] 7
> dims <- c(1,1,2)
I would like a function that I can supply x and dims as parameters to, and have it return 7. Also, I would like to do something like:
> x[1,1,]
[1] 1 7 13 19
> dims2<- c(1,1,NA)
And have a function of x and
2019 Jan 25
0
[klibc:update-dash] [SHELL] Optimize dash -c "command" to avoid a fork
...V_EXIT 01 /* exit after evaluating tree */
-#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
-
int evalskip; /* set if we are skipping commands */
STATIC int skipcount; /* number of levels to skip */
MKINIT int loopnest; /* current loop nesting level */
@@ -169,7 +165,7 @@ evalstring(char *s, int flags)
status = 0;
while ((n = parsecmd(0)) != NEOF) {
- evaltree(n, flags);
+ evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT));
status = exitstatus;
popstackmark(&smark);
if (evalskip)
diff --git a/usr/dash/eval.h b/usr/dash/eval.h
index 5ccfa9f1..dc8acd2...
2020 Mar 28
0
[klibc:update-dash] dash: [SHELL] Optimize dash -c "command" to avoid a fork
...V_EXIT 01 /* exit after evaluating tree */
-#define EV_TESTED 02 /* exit status is checked; ignore -e flag */
-
int evalskip; /* set if we are skipping commands */
STATIC int skipcount; /* number of levels to skip */
MKINIT int loopnest; /* current loop nesting level */
@@ -169,7 +165,7 @@ evalstring(char *s, int flags)
status = 0;
while ((n = parsecmd(0)) != NEOF) {
- evaltree(n, flags);
+ evaltree(n, flags & ~(parser_eof() ? 0 : EV_EXIT));
status = exitstatus;
popstackmark(&smark);
if (evalskip)
diff --git a/usr/dash/eval.h b/usr/dash/eval.h
index 5ccfa9f1..dc8acd2...
2009 Dec 07
2
How to apply five lines of code to ten dataframes?
Hello R-helpers,
I have 10 dataframes (named data1, data2, ... data10) and I would like to
add 5 new columns to each dataframe using the following code:
data1$LogDepth<-log10(data1[,2]/data1[,4])
data1$LogArea<-log10(data1[,3]/data1[,5])
data1$p<-2*data1[,6]/data1[,7]
data1$Exp<-data1[,2]^(2/data1[,8])
data1$s<-data1[,3]/data1[,9]
...but I would prefer not to repeat this chunk of
2019 Jan 25
0
[klibc:update-dash] eval: Fix exit status when calling eval/dot with no commands
...null commands have a visible effect that
should remain.
Note that this fixes the problem with . but the same problem can be
present in other locations. For example,
false
eval "
" && echo OK || echo Fail
used to print Fail, and needed the same modification in the evalstring
function to make that print OK (included in the attached patch). There
may be other similar bugs lurking.
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 | 3 ++-
usr/dash/main.c | 3 ++-
2 files...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Fix exit status when calling eval/dot with no commands
...null commands have a visible effect that
should remain.
Note that this fixes the problem with . but the same problem can be
present in other locations. For example,
false
eval "
" && echo OK || echo Fail
used to print Fail, and needed the same modification in the evalstring
function to make that print OK (included in the attached patch). There
may be other similar bugs lurking.
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 | 3 ++-
usr/dash/main.c | 3 ++-
2 files...
2019 Jan 25
0
[klibc:update-dash] eval: Return status in eval functions
...command(union node *, int, struct backcmd *);
#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...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Return status in eval functions
...command(union node *, int, struct backcmd *);
#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...
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...l shall
> return a zero exit status; otherwise, it shall return the exit
> status of the command defined by the string of concatenated
> arguments separated by <space>s.
>
> Hi Herbert, please see http://bugs.debian.org/347232
Changed evalstring to return the exit status instead of evalskip. This
allows us to return zero if the string is empty.
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: maximilian attems <max at stro.at>
diff --git a/usr/dash/eval.c b/usr/dash/eval.c
index 44...
2019 Jan 25
0
[klibc:update-dash] [TRAP] Make sure evalskip is zero before running traps
...ndingsigs = 0;
barrier();
@@ -322,6 +325,12 @@ void dotrap(void)
for (i = 0, q = gotsig; i < NSIG - 1; i++, q++) {
if (!*q)
continue;
+
+ if (evalskip) {
+ pendingsigs = i + 1;
+ break;
+ }
+
*q = 0;
p = trap[i + 1];
@@ -329,8 +338,6 @@ void dotrap(void)
continue;
evalstring(p, 0);
exitstatus = savestatus;
- if (evalskip)
- break;
}
}
2020 Mar 28
0
[klibc:update-dash] dash: [TRAP] Make sure evalskip is zero before running traps
...ndingsigs = 0;
barrier();
@@ -322,6 +325,12 @@ void dotrap(void)
for (i = 0, q = gotsig; i < NSIG - 1; i++, q++) {
if (!*q)
continue;
+
+ if (evalskip) {
+ pendingsigs = i + 1;
+ break;
+ }
+
*q = 0;
p = trap[i + 1];
@@ -329,8 +338,6 @@ void dotrap(void)
continue;
evalstring(p, 0);
exitstatus = savestatus;
- if (evalskip)
- break;
}
}
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Return without arguments in a trap should use status outside traps
...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
...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: Only restore exit status on exit/return
...de "main.h"
#include "nodes.h" /* for other headers */
#include "eval.h"
+#include "init.h"
#include "jobs.h"
#include "show.h"
#include "options.h"
@@ -396,8 +397,10 @@ exitshell(void)
trap[0] = NULL;
evalskip = 0;
evalstring(p, 0);
+ evalskip = SKIPFUNCDEF;
}
out:
+ exitreset();
/*
* Disable job control so that whoever had the foreground before we
* started can get it back.
@@ -405,7 +408,7 @@ out:
if (likely(!setjmp(loc.loc)))
setjobctl(0);
flushall();
- _exit(savestatus);
+ _exit(exitstatus);...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Exit without arguments in a trap should use status outside traps
...tatus;
if (!pendingsigs)
return;
- savestatus = exitstatus;
+ status = savestatus;
+ last_status = status;
+ if (likely(status < 0)) {
+ status = exitstatus;
+ savestatus = status;
+ }
pendingsigs = 0;
barrier();
@@ -337,8 +342,10 @@ void dotrap(void)
if (!p)
continue;
evalstring(p, 0);
- exitstatus = savestatus;
+ exitstatus = status;
}
+
+ savestatus = last_status;
}
@@ -372,18 +379,14 @@ exitshell(void)
{
struct jmploc loc;
char *p;
- volatile int status;
#ifdef HETIO
hetio_reset_term();
#endif
- status = exitstatus;
- TRACE(("pid %d, exitshel...
[klibc:update-dash] dash: [BUILTIN] Exit without arguments in a trap should use status outside traps
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Exit without arguments in a trap should use status outside traps
...tatus;
if (!pendingsigs)
return;
- savestatus = exitstatus;
+ status = savestatus;
+ last_status = status;
+ if (likely(status < 0)) {
+ status = exitstatus;
+ savestatus = status;
+ }
pendingsigs = 0;
barrier();
@@ -337,8 +342,10 @@ void dotrap(void)
if (!p)
continue;
evalstring(p, 0);
- exitstatus = savestatus;
+ exitstatus = status;
}
+
+ savestatus = last_status;
}
@@ -372,18 +379,14 @@ exitshell(void)
{
struct jmploc loc;
char *p;
- volatile int status;
#ifdef HETIO
hetio_reset_term();
#endif
- status = exitstatus;
- TRACE(("pid %d, exitshel...