BUG/MINOR: http-act: Fix bugs on error path during parsing of return actions

This patch fixes memory leaks and a null pointer dereference found by coverity
on the error path when an HTTP return action is parsed. See issue #491.

No need to backport this patch except the HTT return action is backported too.
This commit is contained in:
Christopher Faulet 2020-02-07 10:26:23 +01:00
parent 692a6c2e69
commit 817c4e39e5
1 changed files with 13 additions and 11 deletions

View File

@ -2053,7 +2053,7 @@ static enum act_parse_ret parse_http_return(const char **args, int *orig_arg, st
cur_arg++; cur_arg++;
if (!*args[cur_arg]) { if (!*args[cur_arg]) {
memprintf(err, "'%s' expects <status_code> as argument", args[cur_arg-1]); memprintf(err, "'%s' expects <status_code> as argument", args[cur_arg-1]);
return ACT_RET_PRS_ERR; goto error;
} }
status = atol(args[cur_arg]); status = atol(args[cur_arg]);
if (status < 200 || status > 599) { if (status < 200 || status > 599) {
@ -2436,6 +2436,7 @@ static enum act_parse_ret parse_http_return(const char **args, int *orig_arg, st
free(name); free(name);
if (fd >= 0) if (fd >= 0)
close(fd); close(fd);
if (hdrs) {
list_for_each_entry_safe(hdr, hdrb, hdrs, list) { list_for_each_entry_safe(hdr, hdrb, hdrs, list) {
LIST_DEL(&hdr->list); LIST_DEL(&hdr->list);
list_for_each_entry_safe(lf, lfb, &hdr->value, list) { list_for_each_entry_safe(lf, lfb, &hdr->value, list) {
@ -2448,6 +2449,7 @@ static enum act_parse_ret parse_http_return(const char **args, int *orig_arg, st
free(hdr); free(hdr);
} }
free(hdrs); free(hdrs);
}
if (action == 3) { if (action == 3) {
list_for_each_entry_safe(lf, lfb, &rule->arg.http_return.body.fmt, list) { list_for_each_entry_safe(lf, lfb, &rule->arg.http_return.body.fmt, list) {
LIST_DEL(&lf->list); LIST_DEL(&lf->list);