]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: jwt: fix jwt_verify crash on 32-bit archs
authorWilly Tarreau <w@1wt.eu>
Wed, 24 Jan 2024 09:31:05 +0000 (10:31 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 24 Jan 2024 09:35:22 +0000 (10:35 +0100)
commite41638af33d76660220ce2e3ed613e8a24fb6e55
tree89145c51684ed247fdfe365c3ec392f384d2802d
parentef02dba7bcf4cf41aaf08fa5cabc8dd2d7537f63
BUG/MINOR: jwt: fix jwt_verify crash on 32-bit archs

The jwt_verify converter was added in 2.5 with commit 130e142ee2
("MEDIUM: jwt: Add jwt_verify converter to verify JWT integrity"). It
takes a string on input and returns an integer. It turns out that by
presetting the return value to zero before processing contents, while
the sample data is a union, it overwrites the beginning of the buffer
struct passed on input. On a 64-bit arch it's not an issue because it's
where the allocated size is stored and it's not used in the operation,
which explains why the regtest works. But on 32-bit, both the size and
the pointer are overwritten, causing a NULL pointer to be passed to
jwt_tokenize() which is not designed to support this, hence crashes.

Let's just use a temporary variable to hold the result and move the
output sample initialization to the end of the function.

This should be backported as far as 2.5.
src/sample.c