This fixes "Buffer overflow in EVP_EncodeBlock()" (CVE-2026-121481) by returning -1 for invalid inputs to EVP_EncodeBlock(): NULL input or output buffers, negative lengths, and lengths for which the encoded size does not fit in an int. The OpenSSL SRT has asked for it to be fixed publicly; the advisory is still pending.
Returning -1 for invalid inputs is the most straightforward fix, and matches what happens in wolfSSL's compatibility layer for OpenSSL's EVP_EncodeBlock().
I'm suggesting a similar guard for EVP_DecodeBlock(). No length limit is needed here because the decoded length always fits in an int, but it is a good idea to reject NULL buffers and negative lengths.
Moreover, I propose to fix the incorrect length check in the base64encode() function of http_client.c, which rejected only len > INT_MAX.
I am adding tests in test/base64_dec_avx2_test.c to cover the new behavior, and documenting the -1 returns in doc/man3/EVP_EncodeInit.pod.
Exploiting this vulnerability from the command line is possible by passing a large -proxy_pass to openssl s_client. I confirmed that GOST accepts these large passwords out of the box. However, the password has to be supplied through an environment variable (env:VAR), otherwise the command line will be too long.
Note: the pattern of CVE-2026-121481 is similar to that of CVE-2021-23840.
- documentation is added or updated
- tests are added or updated