botan: Fix memory leak on failed ICV verification if not using in-place decryption

Fixes: af26cc4d85 ("botan: Add Botan plugin to libstrongswan")
This commit is contained in:
Tobias Brunner
2026-07-22 18:20:12 +02:00
parent a2f83d3075
commit 40aa0a12c4
+8 -2
View File
@@ -164,6 +164,7 @@ METHOD(aead_t, decrypt, bool,
chunk_t *plain) chunk_t *plain)
{ {
u_char *out; u_char *out;
bool valid;
if (encrypted.len < this->icv_size) if (encrypted.len < this->icv_size)
{ {
@@ -177,8 +178,13 @@ METHOD(aead_t, decrypt, bool,
*plain = chunk_alloc(encrypted.len); *plain = chunk_alloc(encrypted.len);
out = plain->ptr; out = plain->ptr;
} }
return do_crypt(this, encrypted, assoc, iv, out, valid = do_crypt(this, encrypted, assoc, iv, out,
BOTAN_CIPHER_INIT_FLAG_DECRYPT); BOTAN_CIPHER_INIT_FLAG_DECRYPT);
if (!valid && plain)
{
chunk_free(plain);
}
return valid;
} }
METHOD(aead_t, get_block_size, size_t, METHOD(aead_t, get_block_size, size_t,