BUG/MINOR: conf: "listener id" expects integer, but its not checked

The listener id was converted with a simple atol, so conversion
error are unchecked. This patch uses strtol and checks the
conversion status.
This commit is contained in:
Thierry Fournier 2016-02-26 08:45:58 +01:00 committed by Willy Tarreau
parent e83345df1b
commit e7fe8eb889

View File

@ -646,6 +646,7 @@ static int bind_parse_id(char **args, int cur_arg, struct proxy *px, struct bind
{
struct eb32_node *node;
struct listener *l, *new;
char *error;
if (conf->listeners.n != conf->listeners.p) {
memprintf(err, "'%s' can only be used with a single socket", args[cur_arg]);
@ -658,7 +659,11 @@ static int bind_parse_id(char **args, int cur_arg, struct proxy *px, struct bind
}
new = LIST_NEXT(&conf->listeners, struct listener *, by_bind);
new->luid = atol(args[cur_arg + 1]);
new->luid = strtol(args[cur_arg + 1], &error, 10);
if (*error != '\0') {
memprintf(err, "'%s' : expects an integer argument, found '%s'", args[cur_arg], args[cur_arg + 1]);
return ERR_ALERT | ERR_FATAL;
}
new->conf.id.key = new->luid;
if (new->luid <= 0) {