Hi Willy,

Please check the attachments for two patches:

Patch0001: MINOR: code style: use tabs to indent codes
Patch0002: DOC: checkcache: block responses with cacheable cookies


There is also another problem I want to talk about stick table. The
following codes are from lastest snapshot:

cfgparse.c/check_config_validity()

    for (curproxy = proxy; curproxy; curproxy = curproxy->next)
        stktable_init(&curproxy->table);

stktable_init() will be called to init stick table in
check_config_validity(). But the returned value is ignored. The codes of
stktable_init() are as below:

int stktable_init(struct stktable *t)
{
    if (t->size) {
        memset(&t->keys, 0, sizeof(t->keys));
        memset(&t->exps, 0, sizeof(t->exps));

        t->pool = create_pool("sticktables", sizeof(struct stksess) +
t->data_size + t->key_size, MEM_F_SHARED);

        ...

        return t->pool != NULL;
    }
    return 1;
}

This function will return false if create_pool() returns NULL. Since the
returned value of this function, HAProxy will crash if t->pool is NULL
and stksess_new() is called to allocate a new stick session.
Of course the probability is a bit. However, in my opinion, the returned
value should be checked as other codes do in check_config_validity(),
the one possibe fix is as follow:
    for (curproxy = proxy; curproxy; curproxy = curproxy->next) {
        if (!stktable_init(&curproxy->table))
            cfgerr++;
    }
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.

-- 
Best Regards,
Godbach
From 35942e286901a50dad02a3cf355f0d943a137eec Mon Sep 17 00:00:00 2001
From: Godbach <[email protected]>
Date: Wed, 11 Dec 2013 19:48:57 +0800
Subject: [PATCH 1/2] MINOR: code style: use tabs to indent codes

The original codes are indented by spaces and not aligned with the former line.
It should be a convention to indent by tabs in HAProxy.

Signed-off-by: Godbach <[email protected]>
---
 src/cfgparse.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/cfgparse.c b/src/cfgparse.c
index 73a08a4..b05bfe9 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -2932,12 +2932,12 @@ int cfg_parse_listen(const char *file, int linenum, 
char **args, int kwm)
                        }
                        else if (strcmp(args[myidx], "peers") == 0) {
                                myidx++;
-                                if (!*(args[myidx])) {
-                                        Alert("parsing [%s:%d] : stick-table: 
missing argument after '%s'.\n",
-                                              file, linenum, args[myidx-1]);
-                                        err_code |= ERR_ALERT | ERR_FATAL;
-                                        goto out;
-                                }
+                               if (!*(args[myidx])) {
+                                       Alert("parsing [%s:%d] : stick-table: 
missing argument after '%s'.\n",
+                                             file, linenum, args[myidx-1]);
+                                       err_code |= ERR_ALERT | ERR_FATAL;
+                                       goto out;
+                               }
                                curproxy->table.peers.name = 
strdup(args[myidx++]);
                        }
                        else if (strcmp(args[myidx], "expire") == 0) {
-- 
1.7.7

From 57d74098da0ab7f5037a220d989b08ca94099db7 Mon Sep 17 00:00:00 2001
From: Godbach <[email protected]>
Date: Wed, 11 Dec 2013 20:01:07 +0800
Subject: [PATCH 2/2] DOC: checkcache: block responses with cacheable cookies

"requests" -> "responses"

Signed-off-by: Godbach <[email protected]>
---
 doc/configuration.txt |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/configuration.txt b/doc/configuration.txt
index 1d13c1e..dda20e3 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -3518,7 +3518,7 @@ no option allbackups
 
 option checkcache
 no option checkcache
-  Analyze all server responses and block requests with cacheable cookies
+  Analyze all server responses and block responses with cacheable cookies
   May be used in sections :   defaults | frontend | listen | backend
                                  yes   |     no   |   yes  |   yes
   Arguments : none
-- 
1.7.7

Reply via email to