summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2007-10-21 21:16:07 +0000
committerClint Adams <clint@users.sourceforge.net>2007-10-21 21:16:07 +0000
commit526f86ec15e12405dfda016cf2bf59dab093d8fa (patch)
treeda1ea8e5b8169fc23aa1a474bfb80fc314085984
parent52ea35c1c6852dd8bacd218e32547afd99c23ba9 (diff)
downloadzsh-526f86ec15e12405dfda016cf2bf59dab093d8fa.tar.gz
zsh-526f86ec15e12405dfda016cf2bf59dab093d8fa.tar.xz
zsh-526f86ec15e12405dfda016cf2bf59dab093d8fa.zip
24005: enforce min/max arguments on zcurses commands.
-rw-r--r--ChangeLog3
-rw-r--r--Src/Modules/curses.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index bd529d7be..5ad19074f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2007-10-21  Clint Adams  <clint@zsh.org>
 
+	* 24005: Src/Modules/curses.c: enforce min/max arguments on zcurses
+	commands.
+
 	* 24004: Doc/Zsh/mod_curses.yo: align documentation with UI changes
 	in 24002.
 
diff --git a/Src/Modules/curses.c b/Src/Modules/curses.c
index aba8028e5..4103d853c 100644
--- a/Src/Modules/curses.c
+++ b/Src/Modules/curses.c
@@ -281,7 +281,7 @@ bin_zcurses(char *nam, char **args, Options ops, UNUSED(int func))
 {
     char **saargs;
     struct zcurses_subcommand *zcsc;
-    int sc;
+    int sc, num_args;
 
     struct zcurses_subcommand scs[] = {
 	{{"init", ZCURSES_SC_INIT}, 0, 0},
@@ -310,7 +310,13 @@ bin_zcurses(char *nam, char **args, Options ops, UNUSED(int func))
 	return 1;
     }
 
-    /* here would be a good place to validate number of args */
+    saargs = args;
+    while (*saargs++);
+    num_args = saargs - (args + 2);
+
+    if (num_args < zcsc->minargs || num_args > zcsc->maxargs)
+	return 1;
+
     saargs = args + 1;
 
     /* Initialise curses */