fix: prevent resource leaks in rsa_crypt() on OpenSSL 3.x#100
Conversation
|
@toddr-bot rebase |
PR Review — fix: prevent resource leaks in rsa_crypt() on OpenSSL 3.xThis PR fixes real bugs (resource leaks in 🔴 Blocking1. PR is stale — OSSL_LIB_CTX already removed on main ( After rebasing onto current 🟡 Important1. Short-circuit chain loses per-step error granularity ( This is moot given the staleness issue above, but worth noting for the pattern. 🟢 Suggestions1. PSS Safefree fix is valid but already merged ( Checklist
SummaryThis PR fixes real bugs (resource leaks in Automated review by Kōan |
Agreed — this PR needs a rebase. Both PR #79 (
After rebasing, this PR will likely conflict on the entire |
|
❌ Permission denied. Only users with write access can trigger bot commands. |
Rebase: fix: prevent resource leaks in rsa_crypt() on OpenSSL 3.xBranch Review feedback was analyzed and applied. Actions
Automated by Kōan |
8c9a950 to
9be6d02
Compare
What
Free
OSSL_LIB_CTX,EVP_PKEY_CTX, and the output buffer on all error paths inrsa_crypt()before croaking.Why
On OpenSSL 3.x,
rsa_crypt()allocates three resources (tobuffer,ossllibctx,ctx) then runs fiveCHECK_OPEN_SSLchecks. EachCHECK_OPEN_SSLexpands tocroakSsl()which does a Perlcroak(longjmp) — skipping the cleanup at lines 356-357. Every failed encrypt/decrypt operation leaks memory.The PSS padding early-exit
croakat line 334 also leaked thetobuffer allocated just above it.How
Replaced five individual
CHECK_OPEN_SSLcalls with a single short-circuit conditional. On failure, all three resources are freed before callingcroakSsl().EVP_PKEY_CTX_free(NULL)andOSSL_LIB_CTX_free(NULL)are documented no-ops, so cleanup is safe regardless of which step fails.Also added
Safefree(to)before the PSS padding croak.Testing
#if-guarded and not compiled on this system; the fix is structural and follows the same cleanup pattern used elsewhere in_new_key_from_parameters()(theerr:label at line 686)EVP_PKEY_CTX_freeandOSSL_LIB_CTX_freeare NULL-safe per OpenSSL docs🤖 Generated with Claude Code
Quality Report
Changes: 1 file changed, 14 insertions(+), 12 deletions(-)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline