search for: stalloc

Displaying 19 results from an estimated 19 matches for "stalloc".

Did you mean: talloc
2020 Mar 28
0
[klibc:update-dash] dash: exec: Do not allocate stack string in padvance
...: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:55 +0000 [klibc] dash: exec: Do not allocate stack string in padvance [ dash commit 4f7527f8e49276894751a9b100e68bc46568bb85 ] Many callers of padvance immediately free the allocated string so this patch moves the stalloc call to the caller. Instead of returning the allocated string, padvance now returns the length to allocate (this may be longer than the actual string length, even including the NUL). For the case where we would previously return NULL, we now return -1. Signed-off-by: Herbert Xu <herbert at go...
2019 Jan 25
0
[klibc:update-dash] parser: use pgetc_eatbnl() in more places
...pe == NHERE? SQSYNTAX : DQSYNTAX, - here->eofmark, here->striptabs); + if (here->here->type == NHERE) + readtoken1(pgetc(), SQSYNTAX, here->eofmark, here->striptabs); + else + readtoken1(pgetc_eatbnl(), DQSYNTAX, here->eofmark, here->striptabs); n = (union node *)stalloc(sizeof (struct narg)); n->narg.type = NARG; n->narg.next = NULL; @@ -782,7 +785,7 @@ xxreadtoken(void) setprompt(2); } for (;;) { /* until token or start of word found */ - c = pgetc(); + c = pgetc_eatbnl(); switch (c) { case ' ': case '\t': case PEOA:...
2020 Mar 28
0
[klibc:update-dash] dash: parser: use pgetc_eatbnl() in more places
...pe == NHERE? SQSYNTAX : DQSYNTAX, - here->eofmark, here->striptabs); + if (here->here->type == NHERE) + readtoken1(pgetc(), SQSYNTAX, here->eofmark, here->striptabs); + else + readtoken1(pgetc_eatbnl(), DQSYNTAX, here->eofmark, here->striptabs); n = (union node *)stalloc(sizeof (struct narg)); n->narg.type = NARG; n->narg.next = NULL; @@ -782,7 +785,7 @@ xxreadtoken(void) setprompt(2); } for (;;) { /* until token or start of word found */ - c = pgetc(); + c = pgetc_eatbnl(); switch (c) { case ' ': case '\t': case PEOA:...
2020 Mar 28
0
[klibc:update-dash] dash: exec: Stricter pathopt parsing
...a/usr/dash/cd.c +++ b/usr/dash/cd.c @@ -128,7 +128,7 @@ dotdot: if (!*dest) dest = "."; path = bltinlookup("CDPATH"); - while (p = path, (len = padvance(&path, dest)) >= 0) { + while (p = path, (len = padvance_magic(&path, dest, 0)) >= 0) { c = *p; p = stalloc(len); diff --git a/usr/dash/exec.c b/usr/dash/exec.c index 04ee2ba9..8948754b 100644 --- a/usr/dash/exec.c +++ b/usr/dash/exec.c @@ -92,7 +92,7 @@ STATIC int builtinloc = -1; /* index in path of %builtin, or -1 */ STATIC void tryexec(char *, char **, char **); STATIC void printentry(struct t...
2019 Jan 25
0
[klibc:update-dash] [BUILTIN] Handle embedded NULs correctly in printf
...+static int xvasprintf(char **sp, size_t size, const char *f, va_list ap) +{ + char *s; + int len; + va_list ap2; + + va_copy(ap2, ap); + len = xvsnprintf(*sp, size, f, ap2); + va_end(ap2); + if (len < 0) + sh_error("xvsnprintf failed"); + if (len < size) + return len; + + s = stalloc((len >= stackblocksize() ? len : stackblocksize()) + 1); + *sp = s; + len = xvsnprintf(s, len + 1, f, ap); + return len; +} + + +int xasprintf(char **sp, const char *f, ...) +{ + va_list ap; + int ret; + + va_start(ap, f); + ret = xvasprintf(sp, 0, f, ap); + va_end(ap); + return ret; +} + + #if...
2020 Mar 28
0
[klibc:update-dash] dash: [BUILTIN] Handle embedded NULs correctly in printf
...+static int xvasprintf(char **sp, size_t size, const char *f, va_list ap) +{ + char *s; + int len; + va_list ap2; + + va_copy(ap2, ap); + len = xvsnprintf(*sp, size, f, ap2); + va_end(ap2); + if (len < 0) + sh_error("xvsnprintf failed"); + if (len < size) + return len; + + s = stalloc((len >= stackblocksize() ? len : stackblocksize()) + 1); + *sp = s; + len = xvsnprintf(s, len + 1, f, ap); + return len; +} + + +int xasprintf(char **sp, const char *f, ...) +{ + va_list ap; + int ret; + + va_start(ap, f); + ret = xvasprintf(sp, 0, f, ap); + va_end(ap); + return ret; +} + + #if...
2020 Mar 28
0
[klibc:update-dash] dash: builtin: Use test_access from NetBSD when faccessat is unavailable
...ur groups list. */ -static int -bash_group_member(gid_t gid) -{ - register int i; - gid_t *group_array; - int ngroups; - - /* Short-circuit if possible, maybe saving a call to getgroups(). */ - if (gid == getgid() || gid == getegid()) - return (1); - - ngroups = getgroups(0, NULL); - group_array = stalloc(ngroups * sizeof(gid_t)); - if ((getgroups(ngroups, group_array)) != ngroups) - return (0); - - /* Search through the list looking for GID. */ - for (i = 0; i < ngroups; i++) - if (gid == group_array[i]) - return (1); + /* any bit is good enough */ + stmode = (stmode << 6) | (stmode...
2019 Jan 25
0
[klibc:update-dash] [EVAL] Fix use-after-free in dotrap/evalstring
...;smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/histedit.c index b27d6294..94465d78 100644 --- a/usr/dash/histedit.c +++ b/usr/dash/histedit.c @@ -372,8 +372,7 @@ histcmd(int argc, char **argv) out2str(s); } - evalstring(strcpy(stalloc(strlen(s) + 1), s), - 0); + evalstring(s, 0); if (displayhist && hist) { /* * XXX what about recursive and
2020 Mar 28
0
[klibc:update-dash] dash: [EVAL] Fix use-after-free in dotrap/evalstring
...;smark); popfile(); + stunalloc(s); return status; } diff --git a/usr/dash/histedit.c b/usr/dash/histedit.c index b27d6294..94465d78 100644 --- a/usr/dash/histedit.c +++ b/usr/dash/histedit.c @@ -372,8 +372,7 @@ histcmd(int argc, char **argv) out2str(s); } - evalstring(strcpy(stalloc(strlen(s) + 1), s), - 0); + evalstring(s, 0); if (displayhist && hist) { /* * XXX what about recursive and
2020 Mar 28
0
[klibc:update-dash] dash: parser: Save/restore here-documents in command substitution
...3db44..809c6a8a 100644 --- a/usr/dash/parser.c +++ b/usr/dash/parser.c @@ -1368,6 +1368,7 @@ parsebackq: { union node *n; char *str; size_t savelen; + struct heredoc *saveheredoclist; int uninitialized_var(saveprompt); str = NULL; @@ -1432,6 +1433,9 @@ done: *nlpp = (struct nodelist *)stalloc(sizeof (struct nodelist)); (*nlpp)->next = NULL; + saveheredoclist = heredoclist; + heredoclist = NULL; + if (oldstyle) { saveprompt = doprompt; doprompt = 0; @@ -1444,17 +1448,18 @@ done: else { if (readtoken() != TRP) synexpect(TRP); + setinputstring(nullstr); + parseher...
2012 Oct 01
0
[klibc:master] Avoid overflow for very long variable name
...r (cond=1, msg=0x417339 "Out of space", ap=0x7fffffffd468) at error.c:156 #4 0x0000000000403938 in sh_error (msg=0x417339 "Out of space") at error.c:172 #5 0x000000000040c970 in ckmalloc (nbytes=18446744071562067984) at memalloc.c:57 #6 0x000000000040ca78 in stalloc (nbytes=18446744071562067972) at memalloc.c:132 #7 0x000000000040ece9 in grabstackblock (len=18446744071562067972) at memalloc.h:67 #8 0x00000000004106b5 in readtoken1 (firstc=118, syntax=0x419522 "", eofmark=0x0, striptabs=0) at parser.c:1040 #9 0x0000000000410...
2020 Mar 28
0
[klibc:update-dash] dash: eval: Always set localvar_stop
...val.c b/usr/dash/eval.c index 7bb636e1..6652ccc0 100644 --- a/usr/dash/eval.c +++ b/usr/dash/eval.c @@ -809,6 +809,8 @@ evalcommand(union node *cmd, int flags) vflags = VEXPORT; } + localvar_stop = pushlocalvars(vlocal); + /* Reserve one extra spot at the front for shellexec. */ nargv = stalloc(sizeof (char *) * (argc + 2)); argv = ++nargv; @@ -828,7 +830,6 @@ evalcommand(union node *cmd, int flags) status = redirectsafe(cmd->ncmd.redirect, REDIR_PUSH|REDIR_SAVEFD2); if (unlikely(status)) { - vlocal = 0; bail: exitstatus = status; @@ -839,9 +840,6 @@ bail: goto out;...
2010 Mar 22
1
[git pull] dash, sh4, README's
...parse-time quote flag detection to run-time [klibc] [PARSER] Recognise here-doc delimiters terminated by EOF [klibc] [PARSER] Fix parsing of ${##1} [klibc] [PARSER] Size optimisations in parameter expansion parser [klibc] [MEMALLOC] Made grabstackblock an inline wrapper for stalloc [klibc] [MEMALLOC] Add pushstackmark [klibc] [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1 [klibc] [VAR] Remove setvarsafe [klibc] [BUILTIN] Use intmax_t arithmetic in test [klibc] [PARSER] Report substition errors at expansion time [klibc] [ARITH] Add ass...
2019 Jan 25
0
[klibc:update-dash] parser: Add syntax stack for recursive parsing
...+++++++++++++++++++-------------------- 3 files changed, 120 insertions(+), 85 deletions(-) diff --git a/usr/dash/expand.c b/usr/dash/expand.c index e86bd29d..2c29ea44 100644 --- a/usr/dash/expand.c +++ b/usr/dash/expand.c @@ -85,7 +85,7 @@ #define RMESCAPE_HEAP 0x10 /* Malloc strings instead of stalloc */ /* Add CTLESC when necessary. */ -#define QUOTES_ESC (EXP_FULL | EXP_CASE | EXP_QPAT) +#define QUOTES_ESC (EXP_FULL | EXP_CASE) /* Do not skip NUL characters. */ #define QUOTES_KEEPNUL EXP_TILDE @@ -335,16 +335,6 @@ addquote: case CTLESC: startloc++; length++; - - /* - * Q...
2020 Mar 28
0
[klibc:update-dash] dash: parser: Add syntax stack for recursive parsing
...+++++++++++++++++++-------------------- 3 files changed, 120 insertions(+), 85 deletions(-) diff --git a/usr/dash/expand.c b/usr/dash/expand.c index e86bd29d..2c29ea44 100644 --- a/usr/dash/expand.c +++ b/usr/dash/expand.c @@ -85,7 +85,7 @@ #define RMESCAPE_HEAP 0x10 /* Malloc strings instead of stalloc */ /* Add CTLESC when necessary. */ -#define QUOTES_ESC (EXP_FULL | EXP_CASE | EXP_QPAT) +#define QUOTES_ESC (EXP_FULL | EXP_CASE) /* Do not skip NUL characters. */ #define QUOTES_KEEPNUL EXP_TILDE @@ -335,16 +335,6 @@ addquote: case CTLESC: startloc++; length++; - - /* - * Q...
2010 Apr 16
0
[git pull v4] dash, sh4, ipconfig, dprintf, fstype, README's
...parse-time quote flag detection to run-time [klibc] [PARSER] Recognise here-doc delimiters terminated by EOF [klibc] [PARSER] Fix parsing of ${##1} [klibc] [PARSER] Size optimisations in parameter expansion parser [klibc] [MEMALLOC] Made grabstackblock an inline wrapper for stalloc [klibc] [MEMALLOC] Add pushstackmark [klibc] [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1 [klibc] [VAR] Remove setvarsafe [klibc] [BUILTIN] Use intmax_t arithmetic in test [klibc] [PARSER] Report substition errors at expansion time [klibc] [ARITH] Add ass...
2010 Apr 16
0
[PATCH] pull faccessat() system call
...parse-time quote flag detection to run-time [klibc] [PARSER] Recognise here-doc delimiters terminated by EOF [klibc] [PARSER] Fix parsing of ${##1} [klibc] [PARSER] Size optimisations in parameter expansion parser [klibc] [MEMALLOC] Made grabstackblock an inline wrapper for stalloc [klibc] [MEMALLOC] Add pushstackmark [klibc] [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1 [klibc] [VAR] Remove setvarsafe [klibc] [BUILTIN] Use intmax_t arithmetic in test [klibc] [PARSER] Report substition errors at expansion time [klibc] [ARITH] Add ass...
2010 Mar 28
1
[git pull v3] dash, sh4, ipconfig, dprintf, fstype, README's
...parse-time quote flag detection to run-time [klibc] [PARSER] Recognise here-doc delimiters terminated by EOF [klibc] [PARSER] Fix parsing of ${##1} [klibc] [PARSER] Size optimisations in parameter expansion parser [klibc] [MEMALLOC] Made grabstackblock an inline wrapper for stalloc [klibc] [MEMALLOC] Add pushstackmark [klibc] [BUILTIN] Treat OPTIND=0 in the same way as OPTIND=1 [klibc] [VAR] Remove setvarsafe [klibc] [BUILTIN] Use intmax_t arithmetic in test [klibc] [PARSER] Report substition errors at expansion time [klibc] [ARITH] Add ass...
2007 Aug 23
0
[git patch] klibc dash 0.5.4 update
...igned-off-by: maximilian attems <max at stro.at> diff --git a/usr/dash/bltin/test.c b/usr/dash/bltin/test.c index 77949de..8f9e085 100644 --- a/usr/dash/bltin/test.c +++ b/usr/dash/bltin/test.c @@ -489,7 +489,8 @@ bash_group_member(gid_t gid) ngroups = getgroups(0, NULL); group_array = stalloc(ngroups * sizeof(gid_t)); - getgroups(ngroups, group_array); + if ((getgroups(ngroups, group_array)) != ngroups) + return (0); /* Search through the list looking for GID. */ for (i = 0; i < ngroups; i++) diff --git a/usr/dash/mkinit.c b/usr/dash/mkinit.c index e803751..9714bee 100644 ---...