From 53d6f476bc7289a9a69f8ccc9ff72c480734ada3 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 1 Sep 2010 14:31:25 +0200 Subject: [PATCH] Sanity-check the stack-limit argument (limit needs to be > 0) --- src/cfgparse.y | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/cfgparse.y b/src/cfgparse.y index 3ba788a9..790ae3be 100644 --- a/src/cfgparse.y +++ b/src/cfgparse.y @@ -393,18 +393,22 @@ new_container: } | TOKNEWCONTAINER WHITESPACE TOKSTACKLIMIT WHITESPACE TOKSTACKLIMIT WHITESPACE NUMBER { - DLOG("stack-limit %d with val %d\n", $5, $7); - config.container_stack_limit = $5; - config.container_stack_limit_value = $7; + if ($7 <= 0) { + ELOG("Invalid stack-limit, need a limit which is > 0\n"); + } else { + DLOG("stack-limit %d with val %d\n", $5, $7); + config.container_stack_limit = $5; + config.container_stack_limit_value = $7; - /* See the comment above */ - Workspace *ws; - TAILQ_FOREACH(ws, workspaces, workspaces) { - if (ws->table == NULL) - continue; - Container *con = ws->table[0][0]; - con->stack_limit = config.container_stack_limit; - con->stack_limit_value = config.container_stack_limit_value; + /* See the comment above */ + Workspace *ws; + TAILQ_FOREACH(ws, workspaces, workspaces) { + if (ws->table == NULL) + continue; + Container *con = ws->table[0][0]; + con->stack_limit = config.container_stack_limit; + con->stack_limit_value = config.container_stack_limit_value; + } } } ;