mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-14 15:34:35 +00:00
BUG/MINOR: config: Reinforce validity check when a process number is parsed
Now, in the function parse_process_number(), when a process number or a set of processes is parsed, an error is triggered if an invalid character is found. It means following syntaxes are not forbidden and will emit an alert during the HAProxy startup: 1a 1/2 1-2-3 This bug was reported on Github. See issue #36. This patch may be backported to 1.9 and 1.8.
This commit is contained in:
parent
11389018bc
commit
18cca781f5
@ -369,16 +369,20 @@ int parse_process_number(const char *arg, unsigned long *proc, int max, int *aut
|
|||||||
else if (strcmp(arg, "even") == 0)
|
else if (strcmp(arg, "even") == 0)
|
||||||
*proc |= (~0UL/3UL) << 1; /* 0xAAA...AAA */
|
*proc |= (~0UL/3UL) << 1; /* 0xAAA...AAA */
|
||||||
else {
|
else {
|
||||||
char *dash;
|
const char *p, *dash = NULL;
|
||||||
unsigned int low, high;
|
unsigned int low, high;
|
||||||
|
|
||||||
if (!isdigit((int)*arg)) {
|
for (p = arg; *p; p++) {
|
||||||
memprintf(err, "'%s' is not a valid number.\n", arg);
|
if (*p == '-' && !dash)
|
||||||
return -1;
|
dash = p;
|
||||||
|
else if (!isdigit((int)*p)) {
|
||||||
|
memprintf(err, "'%s' is not a valid number/range.", arg);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
low = high = str2uic(arg);
|
low = high = str2uic(arg);
|
||||||
if ((dash = strchr(arg, '-')) != NULL)
|
if (dash)
|
||||||
high = ((!*(dash+1)) ? max : str2uic(dash + 1));
|
high = ((!*(dash+1)) ? max : str2uic(dash + 1));
|
||||||
|
|
||||||
if (high < low) {
|
if (high < low) {
|
||||||
|
Loading…
Reference in New Issue
Block a user