BUG/MINOR: tcpcheck: Improve LDAP response parsing to fix LDAP check
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 Sep 2021 14:01:09 +0000 (16:01 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 20 Sep 2021 15:04:09 +0000 (17:04 +0200)
commitd6291d4f0ab21d03a6cb1c9148d0a682407ead17
tree9eaa7460755a8b50e10e11574dbbc468b984d142
parent991d740cbe82f9df14a199270d30c5b2375923e8
BUG/MINOR: tcpcheck: Improve LDAP response parsing to fix LDAP check

When the LDAP response is parsed, the message length is not properly
decoded. While it works for LDAP servers encoding it on 1 byte, it does not
work for those using a multi-bytes encoding. Among others, Active Directory
servers seems to encode messages or elements length on 4 bytes.

In this patch, we only handle length of BindResponse messages encoded on 1,
2 or 4 bytes. In theory, it may be encoded on any bytes number less than 127
bytes. But it is useless to make this part too complex. It should be ok this
way.

This patch should fix the issue #1390. It should be backported to all stable
versions. While it should be easy to backport it as far as 2.2, the patch
will have to be totally rewritten for lower versions.

(cherry picked from commit 8a0e5f822b84c984681547eb0e9ee00d8a19ce56)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 81011211b71b4263ac096d538ba3823e1b693b08)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
reg-tests/checks/ldap-check.vtc
src/tcpcheck.c