87bcafa1b7262065bb8d61bba2a5cb5e0c8e16be
[openwrt-packages.git] /
1 commit 630583cc735de8036ca9963a6e093d5fef90157e
2 Author: Christopher Faulet <cfaulet@haproxy.com>
3 Date:   Tue Jan 14 15:05:56 2020 +0100
4
5     BUG/MINOR: tcp-rules: Fix memory releases on error path during action parsing
6     
7     When an error occurred during the parsing of a TCP action, if some memory was
8     allocated, it should be released before exiting.  Here, the fix consists for
9     replace a call to free() on a sample expression by a call to
10     release_sample_expr().
11     
12     This patch may be backported to all supported versions.
13     
14     (cherry picked from commit fdb6fbfa9a7b730939865b79bfbca3af278113b8)
15     Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
16
17 diff --git a/src/tcp_rules.c b/src/tcp_rules.c
18 index 86b4df538..27cc0c20b 100644
19 --- a/src/tcp_rules.c
20 +++ b/src/tcp_rules.c
21 @@ -694,7 +694,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
22                         memprintf(err,
23                                   "'%s %s %s' : fetch method '%s' extracts information from '%s', none of which is available here",
24                                   args[0], args[1], args[kw], args[arg-1], sample_src_names(expr->fetch->use));
25 -                       free(expr);
26 +                       release_sample_expr(expr);
27                         return -1;
28                 }
29  
30 @@ -704,7 +704,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
31                                 memprintf(err,
32                                           "'%s %s %s' : missing length value",
33                                           args[0], args[1], args[kw]);
34 -                               free(expr);
35 +                               release_sample_expr(expr);
36                                 return -1;
37                         }
38                         /* we copy the table name for now, it will be resolved later */
39 @@ -713,7 +713,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
40                                 memprintf(err,
41                                           "'%s %s %s' : length must be > 0",
42                                           args[0], args[1], args[kw]);
43 -                               free(expr);
44 +                               release_sample_expr(expr);
45                                 return -1;
46                         }
47                         arg++;
48 @@ -772,7 +772,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
49                         memprintf(err,
50                                   "'%s %s %s' : fetch method '%s' extracts information from '%s', none of which is available here",
51                                   args[0], args[1], args[kw], args[arg-1], sample_src_names(expr->fetch->use));
52 -                       free(expr);
53 +                       release_sample_expr(expr);
54                         return -1;
55                 }
56  
57 @@ -785,7 +785,7 @@ static int tcp_parse_request_rule(char **args, int arg, int section_type,
58                                 memprintf(err,
59                                           "'%s %s %s' : missing table name",
60                                           args[0], args[1], args[kw]);
61 -                               free(expr);
62 +                               release_sample_expr(expr);
63                                 return -1;
64                         }
65                         /* we copy the table name for now, it will be resolved later */
git clone https://git.99rst.org/PROJECT