]> git.ipfire.org Git - thirdparty/openssl.git/commit
Fix overflow in EVP_EncodeFinal
authorNeil Horman <nhorman@openssl.org>
Tue, 30 Dec 2025 19:52:08 +0000 (14:52 -0500)
committerNeil Horman <nhorman@openssl.org>
Sun, 4 Jan 2026 22:51:56 +0000 (17:51 -0500)
commitb6aed64e47b831305c05a4132e7c7f21257ea663
tree58539ff53b6a3484e9c44063880e2041ddf8b8f1
parentfb99acc994a916ec1c25d92ab12cdf9155573461
Fix overflow in EVP_EncodeFinal

https://scan5.scan.coverity.com/#/project-view/60762/10222?selectedIssue=1677829

With recent changes, evp_encodeblock_int may return a negative value,
which EVP_EncodeFinal does not anticipate.  As the latter sets out[ret]
to "\0" where ret is the return value of evp_encodeblock_int, we may
underflow the array index and access invalid memory locations.

Only update the output buffer if the return value is greater or equal to
zero.

Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Nikola Pajkovsky <nikolap@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/29525)
crypto/evp/encode.c