Hi Willy,

On 2013/12/11 20:43, Willy Tarreau wrote:
Hi Godbach,


There is also another problem I want to talk about stick table. The
following codes are from lastest snapshot:
(...)
If stktable_init() fails, HAProxy will exit eventually.

I can submit a new patch for this issue if you agree with me about this fix.

yes, feel free to do so!

thanks,
Willy



Please check the attachment for the patch:

Patch0001: BUG/MINOR: check_config_validity: check the returned value of stktable_init()

--
Best Regards,
Godbach
>From 2665f44aa70e313c7e20a0e00cfff6aa5cfb296d Mon Sep 17 00:00:00 2001
From: Godbach <nylzhao...@gmail.com>
Date: Wed, 11 Dec 2013 21:11:41 +0800
Subject: [PATCH] BUG/MINOR: check_config_validity: check the returned value
 of stktable_init()

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 <nylzhao...@gmail.com>
---
 src/cfgparse.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/cfgparse.c b/src/cfgparse.c
index b05bfe9..f9e5191 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -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.
-- 
1.7.7

Reply via email to