BUG/MINOR: sample: The c_str2int converter does not fail if the entry is not an integer

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.
This commit is contained in:
Thierry FOURNIER 2014-01-27 18:20:48 +01:00 committed by Willy Tarreau
parent 59ad9d6593
commit 60bb020d70

View 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;
}