Fix error check for EVP_CTRL_AEAD_GET_TAG

"< 0" is definitely wrong as it can return 0 on error.
Change the checks that are not of the form "== 1" or "!= 1" to "<= 0".

Reviewed-by: Matt Caswell <matt@openssl.foundation>
Reviewed-by: Eugene Syromiatnikov <esyr@openssl.org>
MergeDate: Fri Apr 24 11:29:50 2026
(Merged from https://github.com/openssl/openssl/pull/30923)
This commit is contained in:
ndossche authored and Nikola Pajkovsky committed 2026-04-24 11:29:45 +00:00
1 parent d31fbbeded
commit 674c23d265
3 files changed
+6 -4

No files matched your search

+3 -2
View File
@@ -2958,8 +2958,9 @@ int speed_main(int argc, char **argv)
exit(1);
}
if (!EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, EVP_CTRL_AEAD_GET_TAG,
TAG_LEN, &loopargs[k].tag)) {
if (EVP_CIPHER_CTX_ctrl(loopargs[k].ctx, EVP_CTRL_AEAD_GET_TAG,
TAG_LEN, &loopargs[k].tag)
<= 0) {
BIO_puts(bio_err, "\nFailed to get the tag\n");
dofail();
exit(1);
+1 -1
View File
@@ -105,7 +105,7 @@ unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor,
if (EVP_CIPHER_CTX_is_encrypting(ctx)) {
if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG,
(int)mac_len, out + outlen)
< 0) {
<= 0) {
OPENSSL_free(out);
out = NULL;
ERR_raise(ERR_LIB_PKCS12, ERR_R_INTERNAL_ERROR);
+2 -1
View File
@@ -6242,7 +6242,8 @@ static int test_evp_final_no_tag(int idx)
goto err;
ctext_len += len;
if (!TEST_true(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16, tag)))
if (!TEST_int_gt(EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, 16, tag),
0))
goto err;
EVP_CIPHER_CTX_free(ctx);