]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: sample: The c_str2int converter does not fail if the entry is not an integer
authorThierry FOURNIER <tfournier@exceliance.fr>
Mon, 27 Jan 2014 17:20:48 +0000 (18:20 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 27 Jan 2014 18:04:18 +0000 (19:04 +0100)
If the string not start with a number, the converter fails. In other, it
converts a maximum of characters to a number and stop to the first
character that not match a number.

src/sample.c

index 2a114d9af619c494ee4cc63f595403159c94aa84..f0a346ae6ac5baace3f18b707639083dfc3530c7 100644 (file)
@@ -549,11 +549,17 @@ static int c_str2int(struct sample *smp)
        int i;
        uint32_t ret = 0;
 
+       if (smp->data.str.len == 0)
+               return 0;
+
        for (i = 0; i < smp->data.str.len; i++) {
                uint32_t val = smp->data.str.str[i] - '0';
 
-               if (val > 9)
+               if (val > 9) {
+                       if (i == 0)
+                               return 0;
                        break;
+               }
 
                ret = ret * 10 + val;
        }