]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: ssl: fix several bad pointer aliases in a few sample fetch functions
authorWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 07:59:23 +0000 (08:59 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 25 Feb 2020 07:59:23 +0000 (08:59 +0100)
commit105599c1bab84f67e013a266fd846799c7075b69
treeee81e37f9b8e578d4ac9528a34eb0e9ba3e7d6a5
parent5715da269d6ec1e178b04d1c7aa25982e10873d7
BUG/MEDIUM: ssl: fix several bad pointer aliases in a few sample fetch functions

Sample fetch functions ssl_x_sha1(), ssl_fc_npn(), ssl_fc_alpn(),
ssl_fc_session_id(), as well as the CLI's "show cert details" handler
used to dereference the output buffer's <data> field by casting it to
"unsigned *". But while doing this could work before 1.9, it broke
starting with commit 843b7cbe9d ("MEDIUM: chunks: make the chunk struct's
fields match the buffer struct") which merged chunks and buffers, causing
the <data> field to become a size_t. The impact is only on 64-bit platform
and depends on the endianness: on little endian, there should never be any
non-zero bits in the field as it is supposed to have been zeroed before the
call, so it shouldbe harmless; on big endian, the high part of the value
only is written instead of the lower one, often making the result appear
4 billion times larger, and making such values dropped everywhere due to
being larger than a buffer.

It seems that it would be wise to try to re-enable strict-aliasing to
catch such errors.

This must be backported till 1.9.
src/ssl_sock.c