MINOR: cfgparse/proxy: Group alloc error handling during proxy section parsing

All allocation errors in cfg_parse_listen() are now handled in a unique
place under the "alloc_error" label. This simplify a bit error handling in
this function.
This commit is contained in:
Christopher Faulet 2021-04-12 21:31:45 +02:00
parent b45a7d4b74
commit b15625a43b

View File

@ -387,11 +387,9 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
bind_conf = bind_conf_alloc(curproxy, file, linenum, args[1], xprt_get(XPRT_RAW)); bind_conf = bind_conf_alloc(curproxy, file, linenum, args[1], xprt_get(XPRT_RAW));
if (!bind_conf) { if (!bind_conf)
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
/* use default settings for unix sockets */ /* use default settings for unix sockets */
bind_conf->settings.ux.uid = global.unix_bind.ux.uid; bind_conf->settings.ux.uid = global.unix_bind.ux.uid;
bind_conf->settings.ux.gid = global.unix_bind.ux.gid; bind_conf->settings.ux.gid = global.unix_bind.ux.gid;
@ -496,11 +494,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
free(curproxy->monitor_uri); free(curproxy->monitor_uri);
curproxy->monitor_uri_len = strlen(args[1]); curproxy->monitor_uri_len = strlen(args[1]);
curproxy->monitor_uri = calloc(1, curproxy->monitor_uri_len + 1); curproxy->monitor_uri = calloc(1, curproxy->monitor_uri_len + 1);
if (!curproxy->monitor_uri) { if (!curproxy->monitor_uri)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
memcpy(curproxy->monitor_uri, args[1], curproxy->monitor_uri_len); memcpy(curproxy->monitor_uri, args[1], curproxy->monitor_uri_len);
curproxy->monitor_uri[curproxy->monitor_uri_len] = '\0'; curproxy->monitor_uri[curproxy->monitor_uri_len] = '\0';
@ -586,11 +581,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
len += strlen(args[i]) + 1; len += strlen(args[i]) + 1;
d = calloc(1, len); d = calloc(1, len);
if (!d) { if (!d)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->desc = d; curproxy->desc = d;
d += snprintf(d, curproxy->desc + len - d, "%s", args[1]); d += snprintf(d, curproxy->desc + len - d, "%s", args[1]);
@ -688,11 +680,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
ha_free(&curproxy->cookie_domain); ha_free(&curproxy->cookie_domain);
free(curproxy->cookie_name); free(curproxy->cookie_name);
curproxy->cookie_name = strdup(args[1]); curproxy->cookie_name = strdup(args[1]);
if (!curproxy->cookie_name) { if (!curproxy->cookie_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->cookie_len = strlen(curproxy->cookie_name); curproxy->cookie_len = strlen(curproxy->cookie_name);
cur_arg = 2; cur_arg = 2;
@ -758,12 +747,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
memprintf(&curproxy->cookie_domain, "%s; domain=%s", curproxy->cookie_domain, args[cur_arg+1]); memprintf(&curproxy->cookie_domain, "%s; domain=%s", curproxy->cookie_domain, args[cur_arg+1]);
} }
if (!curproxy->cookie_domain) { if (!curproxy->cookie_domain)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
cur_arg++; cur_arg++;
} }
else if (strcmp(args[cur_arg], "maxidle") == 0) { else if (strcmp(args[cur_arg], "maxidle") == 0) {
@ -863,11 +848,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
else else
memprintf(&curproxy->cookie_attrs, "%s; %s", curproxy->cookie_attrs, args[cur_arg + 1]); memprintf(&curproxy->cookie_attrs, "%s; %s", curproxy->cookie_attrs, args[cur_arg + 1]);
if (!curproxy->cookie_attrs) { if (!curproxy->cookie_attrs)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
cur_arg++; cur_arg++;
} }
@ -914,11 +896,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
free(curproxy->email_alert.from); free(curproxy->email_alert.from);
curproxy->email_alert.from = strdup(args[2]); curproxy->email_alert.from = strdup(args[2]);
if (!curproxy->email_alert.from) { if (!curproxy->email_alert.from)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} }
else if (strcmp(args[1], "mailers") == 0) { else if (strcmp(args[1], "mailers") == 0) {
if (*(args[1]) == 0) { if (*(args[1]) == 0) {
@ -929,11 +908,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
free(curproxy->email_alert.mailers.name); free(curproxy->email_alert.mailers.name);
curproxy->email_alert.mailers.name = strdup(args[2]); curproxy->email_alert.mailers.name = strdup(args[2]);
if (!curproxy->email_alert.mailers.name) { if (!curproxy->email_alert.mailers.name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} }
else if (strcmp(args[1], "myhostname") == 0) { else if (strcmp(args[1], "myhostname") == 0) {
if (*(args[1]) == 0) { if (*(args[1]) == 0) {
@ -944,11 +920,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
free(curproxy->email_alert.myhostname); free(curproxy->email_alert.myhostname);
curproxy->email_alert.myhostname = strdup(args[2]); curproxy->email_alert.myhostname = strdup(args[2]);
if (!curproxy->email_alert.myhostname) { if (!curproxy->email_alert.myhostname)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} }
else if (strcmp(args[1], "level") == 0) { else if (strcmp(args[1], "level") == 0) {
curproxy->email_alert.level = get_log_level(args[2]); curproxy->email_alert.level = get_log_level(args[2]);
@ -968,11 +941,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
free(curproxy->email_alert.to); free(curproxy->email_alert.to);
curproxy->email_alert.to = strdup(args[2]); curproxy->email_alert.to = strdup(args[2]);
if (!curproxy->email_alert.to) { if (!curproxy->email_alert.to)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} }
else { else {
ha_alert("parsing [%s:%d] : email-alert: unknown argument '%s'.\n", ha_alert("parsing [%s:%d] : email-alert: unknown argument '%s'.\n",
@ -1012,21 +982,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
free(curproxy->rdp_cookie_name); free(curproxy->rdp_cookie_name);
curproxy->rdp_cookie_name = my_strndup(beg, end - beg); curproxy->rdp_cookie_name = my_strndup(beg, end - beg);
if (!curproxy->rdp_cookie_name) { if (!curproxy->rdp_cookie_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->rdp_cookie_len = end-beg; curproxy->rdp_cookie_len = end-beg;
} }
else if (*(args[1] + 10) == '\0') { /* default cookie name 'msts' */ else if (*(args[1] + 10) == '\0') { /* default cookie name 'msts' */
free(curproxy->rdp_cookie_name); free(curproxy->rdp_cookie_name);
curproxy->rdp_cookie_name = strdup("msts"); curproxy->rdp_cookie_name = strdup("msts");
if (!curproxy->rdp_cookie_name) { if (!curproxy->rdp_cookie_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->rdp_cookie_len = strlen(curproxy->rdp_cookie_name); curproxy->rdp_cookie_len = strlen(curproxy->rdp_cookie_name);
} }
else { /* syntax */ else { /* syntax */
@ -1080,11 +1044,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
else else
curproxy->server_state_file_name = strdup(args[1]); curproxy->server_state_file_name = strdup(args[1]);
if (!curproxy->server_state_file_name) { if (!curproxy->server_state_file_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} }
else if (strcmp(args[0], "max-session-srv-conns") == 0) { else if (strcmp(args[0], "max-session-srv-conns") == 0) {
if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL)) if (warnifnotcap(curproxy, PR_CAP_FE, file, linenum, args[0], NULL))
@ -1119,11 +1080,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
free(curproxy->capture_name); free(curproxy->capture_name);
curproxy->capture_name = strdup(args[2]); curproxy->capture_name = strdup(args[2]);
if (!curproxy->capture_name) { if (!curproxy->capture_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->capture_namelen = strlen(curproxy->capture_name); curproxy->capture_namelen = strlen(curproxy->capture_name);
curproxy->capture_len = atol(args[4]); curproxy->capture_len = atol(args[4]);
curproxy->to_log |= LW_COOKIE; curproxy->to_log |= LW_COOKIE;
@ -1162,9 +1120,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (hdr) if (hdr)
ha_free(&hdr->name); ha_free(&hdr->name);
ha_free(&hdr); ha_free(&hdr);
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
hdr->index = curproxy->nb_req_cap++; hdr->index = curproxy->nb_req_cap++;
curproxy->req_cap = hdr; curproxy->req_cap = hdr;
@ -1203,9 +1159,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (hdr) if (hdr)
ha_free(&hdr->name); ha_free(&hdr->name);
ha_free(&hdr); ha_free(&hdr);
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
hdr->index = curproxy->nb_rsp_cap++; hdr->index = curproxy->nb_rsp_cap++;
curproxy->rsp_cap = hdr; curproxy->rsp_cap = hdr;
@ -1339,11 +1293,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
/* set the desired header name, in lower case */ /* set the desired header name, in lower case */
free(curproxy->server_id_hdr_name); free(curproxy->server_id_hdr_name);
curproxy->server_id_hdr_name = strdup(args[1]); curproxy->server_id_hdr_name = strdup(args[1]);
if (!curproxy->server_id_hdr_name) { if (!curproxy->server_id_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->server_id_hdr_len = strlen(curproxy->server_id_hdr_name); curproxy->server_id_hdr_len = strlen(curproxy->server_id_hdr_name);
ist2bin_lc(curproxy->server_id_hdr_name, ist2(curproxy->server_id_hdr_name, curproxy->server_id_hdr_len)); ist2bin_lc(curproxy->server_id_hdr_name, ist2(curproxy->server_id_hdr_name, curproxy->server_id_hdr_len));
} }
@ -1427,9 +1378,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (rule) if (rule)
ha_free(&(rule->be.name)); ha_free(&(rule->be.name));
ha_free(&rule); ha_free(&rule);
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
LIST_INIT(&rule->list); LIST_INIT(&rule->list);
LIST_ADDQ(&curproxy->switching_rules, &rule->list); LIST_ADDQ(&curproxy->switching_rules, &rule->list);
@ -1485,9 +1434,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (rule) if (rule)
ha_free(&(rule->srv.name)); ha_free(&(rule->srv.name));
ha_free(&rule); ha_free(&rule);
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
LIST_INIT(&rule->list); LIST_INIT(&rule->list);
LIST_ADDQ(&curproxy->server_rules, &rule->list); LIST_ADDQ(&curproxy->server_rules, &rule->list);
@ -1530,9 +1477,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (cond) if (cond)
prune_acl_cond(cond); prune_acl_cond(cond);
ha_free(&cond); ha_free(&cond);
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
rule->cond = cond; rule->cond = cond;
if (strcmp(args[0], "force-persist") == 0) { if (strcmp(args[0], "force-persist") == 0) {
@ -1700,9 +1645,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (cond) if (cond)
prune_acl_cond(cond); prune_acl_cond(cond);
ha_free(&cond); ha_free(&cond);
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
rule->cond = cond; rule->cond = cond;
rule->expr = expr; rule->expr = expr;
@ -1729,11 +1672,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
goto out; goto out;
} }
if (!stats_check_init_uri_auth(&curproxy->uri_auth)) { if (!stats_check_init_uri_auth(&curproxy->uri_auth))
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
if (strcmp(args[2], "if") != 0 && strcmp(args[2], "unless") != 0) { if (strcmp(args[2], "if") != 0 && strcmp(args[2], "unless") != 0) {
ha_alert("parsing [%s:%d] : '%s %s' requires either 'if' or 'unless' followed by a condition.\n", ha_alert("parsing [%s:%d] : '%s %s' requires either 'if' or 'unless' followed by a condition.\n",
@ -1757,9 +1697,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
if (cond) if (cond)
prune_acl_cond(cond); prune_acl_cond(cond);
ha_free(&cond); ha_free(&cond);
ha_alert("Out of memory error.\n"); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
rule->cond = cond; rule->cond = cond;
LIST_INIT(&rule->list); LIST_INIT(&rule->list);
@ -1769,21 +1707,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
ha_alert("parsing [%s:%d] : 'uri' needs an URI prefix.\n", file, linenum); ha_alert("parsing [%s:%d] : 'uri' needs an URI prefix.\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} else if (!stats_set_uri(&curproxy->uri_auth, args[2])) { } else if (!stats_set_uri(&curproxy->uri_auth, args[2]))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "realm") == 0) { } else if (strcmp(args[1], "realm") == 0) {
if (*(args[2]) == 0) { if (*(args[2]) == 0) {
ha_alert("parsing [%s:%d] : 'realm' needs an realm name.\n", file, linenum); ha_alert("parsing [%s:%d] : 'realm' needs an realm name.\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} else if (!stats_set_realm(&curproxy->uri_auth, args[2])) { } else if (!stats_set_realm(&curproxy->uri_auth, args[2]))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "refresh") == 0) { } else if (strcmp(args[1], "refresh") == 0) {
unsigned interval; unsigned interval;
@ -1805,11 +1737,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
file, linenum, *err); file, linenum, *err);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} else if (!stats_set_refresh(&curproxy->uri_auth, interval)) { } else if (!stats_set_refresh(&curproxy->uri_auth, interval))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "http-request") == 0) { /* request access control: allow/deny/auth */ } else if (strcmp(args[1], "http-request") == 0) { /* request access control: allow/deny/auth */
struct act_rule *rule; struct act_rule *rule;
@ -1819,11 +1748,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
goto out; goto out;
} }
if (!stats_check_init_uri_auth(&curproxy->uri_auth)) { if (!stats_check_init_uri_auth(&curproxy->uri_auth))
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
if (!LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules) && if (!LIST_ISEMPTY(&curproxy->uri_auth->http_req_rules) &&
!LIST_PREV(&curproxy->uri_auth->http_req_rules, struct act_rule *, list)->cond) { !LIST_PREV(&curproxy->uri_auth->http_req_rules, struct act_rule *, list)->cond) {
@ -1849,45 +1775,27 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
ha_alert("parsing [%s:%d] : 'auth' needs a user:password account.\n", file, linenum); ha_alert("parsing [%s:%d] : 'auth' needs a user:password account.\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} else if (!stats_add_auth(&curproxy->uri_auth, args[2])) { } else if (!stats_add_auth(&curproxy->uri_auth, args[2]))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "scope") == 0) { } else if (strcmp(args[1], "scope") == 0) {
if (*(args[2]) == 0) { if (*(args[2]) == 0) {
ha_alert("parsing [%s:%d] : 'scope' needs a proxy name.\n", file, linenum); ha_alert("parsing [%s:%d] : 'scope' needs a proxy name.\n", file, linenum);
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
} else if (!stats_add_scope(&curproxy->uri_auth, args[2])) { } else if (!stats_add_scope(&curproxy->uri_auth, args[2]))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "enable") == 0) { } else if (strcmp(args[1], "enable") == 0) {
if (!stats_check_init_uri_auth(&curproxy->uri_auth)) { if (!stats_check_init_uri_auth(&curproxy->uri_auth))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "hide-version") == 0) { } else if (strcmp(args[1], "hide-version") == 0) {
if (!stats_set_flag(&curproxy->uri_auth, STAT_HIDEVER)) { if (!stats_set_flag(&curproxy->uri_auth, STAT_HIDEVER))
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "show-legends") == 0) { } else if (strcmp(args[1], "show-legends") == 0) {
if (!stats_set_flag(&curproxy->uri_auth, STAT_SHLGNDS)) { if (!stats_set_flag(&curproxy->uri_auth, STAT_SHLGNDS))
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "show-modules") == 0) { } else if (strcmp(args[1], "show-modules") == 0) {
if (!stats_set_flag(&curproxy->uri_auth, STAT_SHMODULES)) { if (!stats_set_flag(&curproxy->uri_auth, STAT_SHMODULES))
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "show-node") == 0) { } else if (strcmp(args[1], "show-node") == 0) {
if (*args[2]) { if (*args[2]) {
@ -1910,11 +1818,8 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
} }
} }
if (!stats_set_node(&curproxy->uri_auth, args[2])) { if (!stats_set_node(&curproxy->uri_auth, args[2]))
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
} else if (strcmp(args[1], "show-desc") == 0) { } else if (strcmp(args[1], "show-desc") == 0) {
char *desc = NULL; char *desc = NULL;
@ -1938,9 +1843,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
else { else {
if (!stats_set_desc(&curproxy->uri_auth, desc)) { if (!stats_set_desc(&curproxy->uri_auth, desc)) {
free(desc); free(desc);
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }
free(desc); free(desc);
} }
@ -2291,11 +2194,8 @@ stats_error_parsing:
free(curproxy->fwdfor_hdr_name); free(curproxy->fwdfor_hdr_name);
curproxy->fwdfor_hdr_name = strdup(DEF_XFORWARDFOR_HDR); curproxy->fwdfor_hdr_name = strdup(DEF_XFORWARDFOR_HDR);
if (!curproxy->fwdfor_hdr_name) { if (!curproxy->fwdfor_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->fwdfor_hdr_len = strlen(DEF_XFORWARDFOR_HDR); curproxy->fwdfor_hdr_len = strlen(DEF_XFORWARDFOR_HDR);
curproxy->except_xff_net.family = AF_UNSPEC; curproxy->except_xff_net.family = AF_UNSPEC;
@ -2337,11 +2237,8 @@ stats_error_parsing:
} }
free(curproxy->fwdfor_hdr_name); free(curproxy->fwdfor_hdr_name);
curproxy->fwdfor_hdr_name = strdup(args[cur_arg+1]); curproxy->fwdfor_hdr_name = strdup(args[cur_arg+1]);
if (!curproxy->fwdfor_hdr_name) { if (!curproxy->fwdfor_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->fwdfor_hdr_len = strlen(curproxy->fwdfor_hdr_name); curproxy->fwdfor_hdr_len = strlen(curproxy->fwdfor_hdr_name);
cur_arg += 2; cur_arg += 2;
} else if (strcmp(args[cur_arg], "if-none") == 0) { } else if (strcmp(args[cur_arg], "if-none") == 0) {
@ -2367,11 +2264,8 @@ stats_error_parsing:
free(curproxy->orgto_hdr_name); free(curproxy->orgto_hdr_name);
curproxy->orgto_hdr_name = strdup(DEF_XORIGINALTO_HDR); curproxy->orgto_hdr_name = strdup(DEF_XORIGINALTO_HDR);
if (!curproxy->orgto_hdr_name) { if (!curproxy->orgto_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->orgto_hdr_len = strlen(DEF_XORIGINALTO_HDR); curproxy->orgto_hdr_len = strlen(DEF_XORIGINALTO_HDR);
curproxy->except_xot_net.family = AF_UNSPEC; curproxy->except_xot_net.family = AF_UNSPEC;
@ -2412,11 +2306,8 @@ stats_error_parsing:
} }
free(curproxy->orgto_hdr_name); free(curproxy->orgto_hdr_name);
curproxy->orgto_hdr_name = strdup(args[cur_arg+1]); curproxy->orgto_hdr_name = strdup(args[cur_arg+1]);
if (!curproxy->orgto_hdr_name) { if (!curproxy->orgto_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->orgto_hdr_len = strlen(curproxy->orgto_hdr_name); curproxy->orgto_hdr_len = strlen(curproxy->orgto_hdr_name);
cur_arg += 2; cur_arg += 2;
} else { } else {
@ -2452,11 +2343,8 @@ stats_error_parsing:
} }
free(curproxy->defbe.name); free(curproxy->defbe.name);
curproxy->defbe.name = strdup(args[1]); curproxy->defbe.name = strdup(args[1]);
if (!curproxy->defbe.name) { if (!curproxy->defbe.name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
if (alertif_too_many_args_idx(1, 0, file, linenum, args, &err_code)) if (alertif_too_many_args_idx(1, 0, file, linenum, args, &err_code))
goto out; goto out;
@ -2748,11 +2636,8 @@ stats_error_parsing:
} }
free(curproxy->conf.uniqueid_format_string); free(curproxy->conf.uniqueid_format_string);
curproxy->conf.uniqueid_format_string = strdup(args[1]); curproxy->conf.uniqueid_format_string = strdup(args[1]);
if (!curproxy->conf.uniqueid_format_string) { if (!curproxy->conf.uniqueid_format_string)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
free(curproxy->conf.uif_file); free(curproxy->conf.uif_file);
curproxy->conf.uif_file = strdup(curproxy->conf.args.file); curproxy->conf.uif_file = strdup(curproxy->conf.args.file);
@ -2805,11 +2690,8 @@ stats_error_parsing:
curproxy->conf.logformat_string != clf_http_log_format) curproxy->conf.logformat_string != clf_http_log_format)
free(curproxy->conf.logformat_string); free(curproxy->conf.logformat_string);
curproxy->conf.logformat_string = strdup(args[1]); curproxy->conf.logformat_string = strdup(args[1]);
if (!curproxy->conf.logformat_string) { if (!curproxy->conf.logformat_string)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
free(curproxy->conf.lfs_file); free(curproxy->conf.lfs_file);
curproxy->conf.lfs_file = strdup(curproxy->conf.args.file); curproxy->conf.lfs_file = strdup(curproxy->conf.args.file);
@ -2839,11 +2721,8 @@ stats_error_parsing:
if (curproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format) if (curproxy->conf.logformat_sd_string != default_rfc5424_sd_log_format)
free(curproxy->conf.logformat_sd_string); free(curproxy->conf.logformat_sd_string);
curproxy->conf.logformat_sd_string = strdup(args[1]); curproxy->conf.logformat_sd_string = strdup(args[1]);
if (!curproxy->conf.logformat_sd_string) { if (!curproxy->conf.logformat_sd_string)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
free(curproxy->conf.lfsd_file); free(curproxy->conf.lfsd_file);
curproxy->conf.lfsd_file = strdup(curproxy->conf.args.file); curproxy->conf.lfsd_file = strdup(curproxy->conf.args.file);
@ -2944,11 +2823,8 @@ stats_error_parsing:
curproxy->conn_src.opts |= CO_SRC_TPROXY_DYN; curproxy->conn_src.opts |= CO_SRC_TPROXY_DYN;
free(curproxy->conn_src.bind_hdr_name); free(curproxy->conn_src.bind_hdr_name);
curproxy->conn_src.bind_hdr_name = calloc(1, end - name + 1); curproxy->conn_src.bind_hdr_name = calloc(1, end - name + 1);
if (!curproxy->conn_src.bind_hdr_name) { if (!curproxy->conn_src.bind_hdr_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->conn_src.bind_hdr_len = end - name; curproxy->conn_src.bind_hdr_len = end - name;
memcpy(curproxy->conn_src.bind_hdr_name, name, end - name); memcpy(curproxy->conn_src.bind_hdr_name, name, end - name);
curproxy->conn_src.bind_hdr_name[end-name] = '\0'; curproxy->conn_src.bind_hdr_name[end-name] = '\0';
@ -3010,11 +2886,8 @@ stats_error_parsing:
} }
free(curproxy->conn_src.iface_name); free(curproxy->conn_src.iface_name);
curproxy->conn_src.iface_name = strdup(args[cur_arg + 1]); curproxy->conn_src.iface_name = strdup(args[cur_arg + 1]);
if (!curproxy->conn_src.iface_name) { if (!curproxy->conn_src.iface_name)
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum); goto alloc_error;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
curproxy->conn_src.iface_len = strlen(curproxy->conn_src.iface_name); curproxy->conn_src.iface_len = strlen(curproxy->conn_src.iface_name);
global.last_checks |= LSTCHK_NETADM; global.last_checks |= LSTCHK_NETADM;
#else #else
@ -3195,4 +3068,9 @@ stats_error_parsing:
out: out:
free(errmsg); free(errmsg);
return err_code; return err_code;
alloc_error:
ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
} }