]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: http-rules: Don't free new rule on allocation failure
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 21 Mar 2022 07:21:19 +0000 (08:21 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 21 Mar 2022 07:24:17 +0000 (08:24 +0100)
If allocation of a new HTTP rule fails, we must not release it calling
free_act_rule(). The regression was introduced by the commit dd7e6c6dc
("BUG/MINOR: http-rules: completely free incorrect TCP rules on error").

This patch must only be backported if the commit above is backported. It should
fix the issues #1627, #1628 and #1629.

src/http_rules.c

index 9314d5aa71d5482761127c4f4c127fbfe14e043c..d3f41bf14c90c812eae2dff01410afaba7e896e2 100644 (file)
@@ -99,7 +99,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
        rule = new_act_rule(ACT_F_HTTP_REQ, file, linenum);
        if (!rule) {
                ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
-               goto out_err;
+               goto out;
        }
 
        if (((custom = action_http_req_custom(args[0])) != NULL)) {
@@ -164,6 +164,7 @@ struct act_rule *parse_http_req_cond(const char **args, const char *file, int li
        return rule;
  out_err:
        free_act_rule(rule);
+ out:
        return NULL;
 }
 
@@ -177,7 +178,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li
        rule = new_act_rule(ACT_F_HTTP_RES, file, linenum);
        if (!rule) {
                ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
-               goto out_err;
+               goto out;
        }
 
        if (((custom = action_http_res_custom(args[0])) != NULL)) {
@@ -242,6 +243,7 @@ struct act_rule *parse_http_res_cond(const char **args, const char *file, int li
        return rule;
  out_err:
        free_act_rule(rule);
+ out:
        return NULL;
 }
 
@@ -256,7 +258,7 @@ struct act_rule *parse_http_after_res_cond(const char **args, const char *file,
        rule = new_act_rule(ACT_F_HTTP_RES, file, linenum);
        if (!rule) {
                ha_alert("parsing [%s:%d]: out of memory.\n", file, linenum);
-               goto out_err;
+               goto out;
        }
 
        if (((custom = action_http_after_res_custom(args[0])) != NULL)) {
@@ -311,6 +313,7 @@ struct act_rule *parse_http_after_res_cond(const char **args, const char *file,
        return rule;
  out_err:
        free_act_rule(rule);
+ out:
        return NULL;
 }