]> git.ipfire.org Git - thirdparty/openssl.git/commit
Ensure cmd from fuzz buffer is always valid
authorNeil Horman <nhorman@openssl.org>
Tue, 9 Jul 2024 19:43:56 +0000 (15:43 -0400)
committerNeil Horman <nhorman@openssl.org>
Tue, 23 Jul 2024 12:20:15 +0000 (08:20 -0400)
commit4f619ca622b6c36626ddc9a04b0b8589d7802dc0
tree1dd840c8c4300d428ecd3d2a030d0a6c15d579dd
parentaececda752d182f271bf2263f5ef9020a64668c5
Ensure cmd from fuzz buffer is always valid

The quic-srtm fuzzer uses a loop in which an integer command is
extracted from the fuzzer buffer input to determine the action to take,
switching on the values between 0 and 3, and ignoring all other
commands.  Howver in the failing fuzzer test case here:
https://oss-fuzz.com/testcase-detail/5618331942977536

The buffer provided shows a large number of 0 values (indicating an SRTM
add command), and almost no 1, 2, or 3 values.  As such, the fuzzer only
truly exercises the srtm add path, which has the side effect of growing
the SRTM hash table unboundedly, leading to a timeout when 10 entries
need to be iterated over when the hashtable doall command is executed.

Fix this by ensuring that the command is always valid, and reasonably
distributed among all the operations with some modulo math.

Introducing this change bounds the hash table size in the reproducer
test case to less than half of the initially observed size, and avoids
the timeout.

Fixes openssl/project#679

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24827)
fuzz/quic-srtm.c