BUG/MINOR: payload: Wait for more data if buffer is empty in payload/payload_lv
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 29 Mar 2021 09:09:45 +0000 (11:09 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 30 Mar 2021 16:07:49 +0000 (18:07 +0200)
commit0e2cf434cae546fd20073f3999ed5a195f54503d
tree17a279e4dd62ea058dd52ed3ac2f26ecd0a1af3d
parent5e22cf3a9e598f0adb9701dc1837d30d95cfaa5f
BUG/MINOR: payload: Wait for more data if buffer is empty in payload/payload_lv

In payload() and payload_lv() sample fetches, if the buffer is empty, we
must wait for more data by setting SMP_F_MAY_CHANGE flag on the sample.
Otherwise, when it happens in an ACL, nothing is returned (because the
buffer is empty) and the ACL is considered as finished (success or failure
depending on the test).

As a workaround, the buffer length may be tested first. For instance :

    tcp-request inspect-delay 1s
    tcp-request content reject unless { req.len gt 0 } { req.payload(0,0),fix_is_valid }

instead of :

    tcp-request inspect-delay 1s
    tcp-request content reject if ! { req.payload(0,0),fix_is_valid }

This patch must be backported as far as 2.2.

(cherry picked from commit 50623029f8171f7f499529f8002d3093fca12667)
Signed-off-by: Willy Tarreau <w@1wt.eu>
src/payload.c