BUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 12 May 2021 08:17:47 +0000 (10:17 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 12 May 2021 13:30:03 +0000 (15:30 +0200)
commitc460c70ab745d68285b3de39da09751976e300ae
tree5dace3322042cb7e2452b14afdc03175713c6f0e
parent40a871f09d13dc666ebe0f97ed576ca93c5ff38c
BUG/MEDIUM: stick_table: fix crash when using tcp smp_fetch_src

Since the introduction of bc_src, smp_fetch_src from tcp_sample inspect
the kw argument to choose between the frontend or the backend source
address. However, for the stick tables, the argument is left to NULL.
This causes a segfault.

Fix the crash by explicitely set the kw argument to "src" to retrieve
the source address of the frontend side.

This bug was introduced by the following commit :
  7d081f02a43651d781a3a30a51ae19abdceb5683
  MINOR: tcp_samples: Add samples to get src/dst info of the backend connection

It does not need a backport as it is integrated in the current 2.4-dev
branch.

To reproduce the crash, I used the following config :

frontend fe
bind :20080
http-request track-sc0 src table foo
http-request reject if { src_conn_rate(foo) gt 10 }
use_backend h1

backend foo
stick-table type ip size 200k expire 30s store conn_rate(60s)

backend h1
server nginx 127.0.0.1:30080 check

This should fix the github issue #1247.
src/stick_table.c