Hi Willy,

Attached is a patch for parse_size_err().

If a stick table is defined as below:
        stick-table type ip size 50ka expire 300s

HAProxy will stop parsing size after passing through "50k" and return the value directly. But such format string of size should not be valid in my opinion. So a further check is needed, that is this patch does.

With this patch, we will get the error message when start HAProxy with the above configuration of stick table:

[ALERT] 027/175100 (22532) : parsing [h.cfg:53] : stick-table: unexpected character 'a' in argument of 'size'.

If you think it is necessary to apply this patch, both 1.6 and 1.5 need it.

--
Best Regards,
Godbach
From 174943fb20fb3b45f186a6536b53151bdf00fee7 Mon Sep 17 00:00:00 2001
From: Godbach <[email protected]>
Date: Wed, 28 Jan 2015 17:36:16 +0800
Subject: [PATCH] BUG/MINOR: parse: check the validity of size string in a
 more strict way

If a stick table is defined as below:
        stick-table type ip size 50ka expire 300s

HAProxy will stop parsing size after passing through "50k" and return the value
directly. But such format string of size should not be valid. The patch checks
the next character to report error if any.

Signed-off-by: Godbach <[email protected]>
---
 src/standard.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/standard.c b/src/standard.c
index 93c44bb..f28825f 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -1656,6 +1656,9 @@ const char *parse_size_err(const char *text, unsigned 
*ret) {
                return text;
        }
 
+       if (*text != '\0' && *++text != '\0')
+               return text;
+
        *ret = value;
        return NULL;
 }
-- 
1.7.11.7

Reply via email to