* PATCH: max-function-depth configure option
@ 2000-04-07 2:18 Clint Adams
0 siblings, 0 replies; only message in thread
From: Clint Adams @ 2000-04-07 2:18 UTC (permalink / raw)
To: zsh-workers
This allows someone to hardcode the number of nested functions
the shell will allow. The resulting behavior is hardly ideal,
but I can't figure out what would be ideal. Exiting completely?
Index: acconfig.h
===================================================================
RCS file: /cvsroot/zsh/zsh/acconfig.h,v
retrieving revision 1.1.1.14
diff -u -r1.1.1.14 acconfig.h
--- acconfig.h 2000/02/28 04:36:33 1.1.1.14
+++ acconfig.h 2000/04/07 02:02:18
@@ -169,6 +169,9 @@
/* Define for Maildir support */
#undef MAILDIR_SUPPORT
+/* Define for function depth limits */
+#undef MAX_FUNCTION_DEPTH
+
/* Define if you want locale features. By default this is defined. */
#undef CONFIG_LOCALE
Index: configure.in
===================================================================
RCS file: /cvsroot/zsh/zsh/configure.in,v
retrieving revision 1.2
diff -u -r1.2 configure.in
--- configure.in 2000/04/06 16:44:03 1.2
+++ configure.in 2000/04/07 02:02:18
@@ -271,6 +271,16 @@
AC_DEFINE(MAILDIR_SUPPORT)
fi])
+dnl Do you want to set a maximum function depth?
+undefine([max_function_depth])dnl
+AC_ARG_ENABLE(max-function-depth,
+[ --enable-max-function-depth=MAX Limit function depth to MAX],
+[if test x$enableval = xyes; then
+ AC_DEFINE(MAX_FUNCTION_DEPTH, 4096)
+else
+ AC_DEFINE_UNQUOTED(MAX_FUNCTION_DEPTH, $enableval)
+fi])
+
dnl ------------------
dnl CHECK THE COMPILER
dnl ------------------
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.2
diff -u -r1.2 exec.c
--- Src/exec.c 2000/04/01 20:49:48 1.2
+++ Src/exec.c 2000/04/07 02:02:19
@@ -3251,6 +3251,9 @@
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 @@
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 @@
}
runshfunc(prog, wrappers, fstack.name);
funcstack = fstack.prev;
+#ifdef MAX_FUNCTION_DEPTH
+ --funcdepth;
+#endif
if (retflag) {
retflag = 0;
breaks = obreaks;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2000-04-07 2:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-07 2:18 PATCH: max-function-depth configure option Clint Adams
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).