]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: stick-table: fix regression caused by a change in proxy struct
authorDragan Dosen <ddosen@haproxy.com>
Tue, 7 May 2019 12:16:18 +0000 (14:16 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 May 2019 12:56:59 +0000 (14:56 +0200)
In commit 1b8e68e ("MEDIUM: stick-table: Stop handling stick-tables as
proxies."), the ->table member of proxy struct was replaced by a pointer
that is not always checked and in some situations can cause a segfault,
eg. during reload or while using "show table" on CLI socket.

No backport is needed.

src/cfgparse.c
src/haproxy.c
src/stick_table.c

index b0d1f5df8c7d2f83f7be75e6416e5ea23355683b..3188d50e840fae1ac625202387b8100549e7894c 100644 (file)
@@ -2320,8 +2320,10 @@ int check_config_validity()
                if (curproxy->state == PR_STSTOPPED) {
                        /* ensure we don't keep listeners uselessly bound */
                        stop_proxy(curproxy);
-                       free((void *)curproxy->table->peers.name);
-                       curproxy->table->peers.p = NULL;
+                       if (curproxy->table) {
+                               free((void *)curproxy->table->peers.name);
+                               curproxy->table->peers.p = NULL;
+                       }
                        continue;
                }
 
index 33f2e9ddb68a1862406d2d09a134a21f3ea23100..f709224c584e917a0fe77f5b9ef109313ff07aea 100644 (file)
@@ -2367,7 +2367,8 @@ void deinit(void)
 
                pool_destroy(p->req_cap_pool);
                pool_destroy(p->rsp_cap_pool);
-               pool_destroy(p->table->pool);
+               if (p->table)
+                       pool_destroy(p->table->pool);
 
                p0 = p;
                p = p->next;
index d7e1eb8afaa74cdab447b3b1f5f0b30a7df3b0ee..1263ca4c4b897cb23a9ea97bd10ec6bb3617345c 100644 (file)
@@ -3588,7 +3588,8 @@ static int table_prepare_data_request(struct appctx *appctx, char **args)
                return 1;
        }
 
-       if (!((struct proxy *)appctx->ctx.table.target)->table->data_ofs[appctx->ctx.table.data_type]) {
+       if (!((struct proxy *)appctx->ctx.table.target)->table ||
+           !((struct proxy *)appctx->ctx.table.target)->table->data_ofs[appctx->ctx.table.data_type]) {
                appctx->ctx.cli.severity = LOG_ERR;
                appctx->ctx.cli.msg = "Data type not stored in this table\n";
                appctx->st0 = CLI_ST_PRINT;