1 commit be17bb8fc37db4e12ea24c9480ff6442017ff656
2 Author: Christopher Faulet <cfaulet@haproxy.com>
3 Date: Fri Sep 13 15:15:56 2019 +0200
5 BUG/MEDIUM: stick-table: Properly handle "show table" with a data type argument
7 Since the commit 1b8e68e8 ("MEDIUM: stick-table: Stop handling stick-tables as
8 proxies."), the target field into the table context of the CLI applet was not
9 anymore a pointer to a proxy. It was replaced by a pointer to a stktable. But,
10 some parts of the code was not updated accordingly. the function
11 table_prepare_data_request() still tries to cast it to a pointer to a proxy. The
12 result is totally undefined. With a bit of luck, when the "show table" command
13 is used with a data type, we failed to find a table and the error "Data type not
14 stored in this table" is returned. But crashes may also be experienced.
16 This patch fixes the issue #262. It must be backported to 2.0.
18 (cherry picked from commit 4e9a83349a9b523830f79f9632ef777ab0bfcc9d)
19 Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
21 diff --git a/src/stick_table.c b/src/stick_table.c
22 index 4b04f18c..8528baa0 100644
23 --- a/src/stick_table.c
24 +++ b/src/stick_table.c
25 @@ -3601,8 +3601,7 @@ static int table_prepare_data_request(struct appctx *appctx, char **args)
29 - if (!((struct proxy *)appctx->ctx.table.target)->table ||
30 - !((struct proxy *)appctx->ctx.table.target)->table->data_ofs[appctx->ctx.table.data_type]) {
31 + if (!((struct stktable *)appctx->ctx.table.target)->data_ofs[appctx->ctx.table.data_type]) {
32 appctx->ctx.cli.severity = LOG_ERR;
33 appctx->ctx.cli.msg = "Data type not stored in this table\n";
34 appctx->st0 = CLI_ST_PRINT;