mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-15 02:00:56 +00:00
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:
parent
59ad9d6593
commit
60bb020d70
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user