diff options
Diffstat (limited to 'Src')
-rw-r--r-- | Src/exec.c | 13 | ||||
-rw-r--r-- | Src/glob.c | 4 |
2 files changed, 16 insertions, 1 deletions
diff --git a/Src/exec.c b/Src/exec.c index 0dffaf4e2..79dca611d 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3251,6 +3251,9 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) char saveopts[OPT_SIZE], *oldscriptname = NULL, *fname = dupstring(name); int obreaks; struct funcstack fstack; +#ifdef MAX_FUNCTION_DEPTH + static int funcdepth; +#endif pushheap(); @@ -3300,6 +3303,13 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) argzero = ztrdup(argzero); } } +#ifdef MAX_FUNCTION_DEPTH + if(++funcdepth > MAX_FUNCTION_DEPTH) + { + zerr("maximum nested function level reached", NULL, 0); + return; + } +#endif fstack.name = dupstring(name); fstack.prev = funcstack; funcstack = &fstack; @@ -3323,6 +3333,9 @@ doshfunc(char *name, Eprog prog, LinkList doshargs, int flags, int noreturnval) } runshfunc(prog, wrappers, fstack.name); funcstack = fstack.prev; +#ifdef MAX_FUNCTION_DEPTH + --funcdepth; +#endif if (retflag) { retflag = 0; breaks = obreaks; diff --git a/Src/glob.c b/Src/glob.c index 663e0167f..623a50706 100644 --- a/Src/glob.c +++ b/Src/glob.c @@ -698,6 +698,8 @@ parsecomplist(char *instr) static Complist parsepat(char *str) { + long assert; + patcompstart(); /* * Check for initial globbing flags, so that they don't form @@ -707,7 +709,7 @@ parsepat(char *str) (isset(KSHGLOB) && *str == '@' && str[1] == Inpar && str[2] == Pound)) { str += (*str == Inpar) ? 2 : 3; - if (!patgetglobflags(&str)) + if (!patgetglobflags(&str, &assert)) return NULL; } |