]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: backend: fix potential null deref on srv_conn
authorWilly Tarreau <w@1wt.eu>
Wed, 15 Jul 2020 15:46:32 +0000 (17:46 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 15 Jul 2020 15:46:32 +0000 (17:46 +0200)
commitdc2ac81c41b2628ea1f37a915d377dc51e922e16
treef125bc5e49c833827f839bcbe3308a86dddbd957
parent3b3096ede1b52007fa49a563436df8ee9323d78c
BUG/MINOR: backend: fix potential null deref on srv_conn

Commit 08016ab82 ("MEDIUM: connection: Add private connections
synchronously in session server list") introduced a build warning about
a potential null dereference which is actually true: in case a reuse
fails an we fail to allocate a new connection, we could crash. The
issue was already present earlier but the compiler couldn't detect
it since it was guarded by an independent condition.

This should be carefully backported to older versions (at least 2.2
and maybe 2.1), the change consists in only adding a test on srv_conn.

The whole sequence of "if" blocks is ugly there and would deserve being
cleaned up so that the !srv_conn condition is matched ASAP and the
assignment is done later. This would remove complicated conditions.
src/backend.c