]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: check_config_validity: check the returned value of stktable_init()
authorGodbach <nylzhaowei@gmail.com>
Wed, 11 Dec 2013 13:11:41 +0000 (21:11 +0800)
committerWilly Tarreau <w@1wt.eu>
Wed, 11 Dec 2013 13:47:05 +0000 (14:47 +0100)
The function stktable_init() will return 0 if create_pool() returns NULL. Since
the returned value of this function is ignored, HAProxy will crash if the pool
of stick table is NULL and stksess_new() is called to allocate a new stick
session. It is a better choice to check the returned value and make HAProxy exit
with alert message if any error is caught.

Signed-off-by: Godbach <nylzhaowei@gmail.com>
src/cfgparse.c

index b05bfe93a3ad33635a9aa675b3990069e11d43fe..f9e51913f1a7851862f7901fde1cf1e3105b1d16 100644 (file)
@@ -7535,8 +7535,12 @@ out_uri_auth_compat:
         * be done earlier because the data size may be discovered while parsing
         * other proxies.
         */
-       for (curproxy = proxy; curproxy; curproxy = curproxy->next)
-               stktable_init(&curproxy->table);
+       for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
+               if (!stktable_init(&curproxy->table)) {
+                       Alert("Proxy '%s': failed to initialize stick-table.\n", curproxy->id);
+                       cfgerr++;
+               }
+       }
 
        /*
         * Recount currently required checks.