Skip to content

fix: drain error queue in _get_key_parameters() on 3.x#164

Merged
timlegge merged 1 commit into
cpan-authors:mainfrom
atoomic:koan.atoomic/get-key-params-no-croak
Apr 5, 2026
Merged

fix: drain error queue in _get_key_parameters() on 3.x#164
timlegge merged 1 commit into
cpan-authors:mainfrom
atoomic:koan.atoomic/get-key-params-no-croak

Conversation

@Koan-Bot
Copy link
Copy Markdown
Contributor

@Koan-Bot Koan-Bot commented Apr 3, 2026

What

Add ERR_clear_error() after the EVP_PKEY_get_bn_param() calls in _get_key_parameters() on the OpenSSL 3.x path, and add a test codifying the undef-for-missing-params contract.

Why

Per review feedback on PR #159 from @timlegge: the contracted API returns undef for any parameter that cannot be retrieved — it should not croak. The current code already does this correctly (NULL → cor_bn2sv(NULL) → undef), but failed EVP_PKEY_get_bn_param() calls push errors onto the OpenSSL error queue that could leak into the next croakSsl() call from an unrelated operation.

How

  • Add ERR_clear_error() after all 8 EVP_PKEY_get_bn_param() calls to drain stale errors
  • No behavioral change — missing params still return undef, matching pre-3.x exactly
  • New t/get_key_parameters.t (10 tests) codifies the API contract for both private and public keys

Testing

  • 548 tests pass (full suite)
  • New test validates: private key returns 8 defined values, public key returns n/e defined + 6 undef

Supersedes #159. Addresses review feedback from @timlegge.

🤖 Generated with Claude Code


Quality Report

Changes: 3 files changed, 51 insertions(+)

Code scan: clean

Tests: passed (OK)

Branch hygiene: clean

Generated by Kōan post-mission quality pipeline

@timlegge
Copy link
Copy Markdown
Member

timlegge commented Apr 5, 2026

@Koan-Bot this looks like it can close

@Koan-Bot Koan-Bot marked this pull request as ready for review April 5, 2026 03:37
@timlegge
Copy link
Copy Markdown
Member

timlegge commented Apr 5, 2026

@Koan-Bot rebase from main

EVP_PKEY_get_bn_param() pushes errors onto the OpenSSL error queue
when a parameter is absent (e.g. private components on a public key).
These stale errors could leak into the next croakSsl() call from an
unrelated operation.

Add ERR_clear_error() after the parameter extraction calls.  The API
contract is preserved: missing parameters return undef (via
cor_bn2sv(NULL)), matching the pre-3.x behavior exactly.

Add t/get_key_parameters.t to codify this contract: private keys
return 8 defined values, public keys return n/e defined + 6 undef.

Addresses review feedback on PR cpan-authors#159.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot
Copy link
Copy Markdown
Contributor Author

Koan-Bot commented Apr 5, 2026

Rebase: fix: drain error queue in _get_key_parameters() on 3.x

Branch koan.atoomic/get-key-params-no-croak rebased onto main and force-pushed.

Diff: 2 files changed, 4 insertions(+), 1 deletion(-)

Review feedback was analyzed and applied.

Actions

  • Already-solved check: skipped (Claude call failed)
  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/get-key-params-no-croak onto upstream/main
  • Force-pushed koan.atoomic/get-key-params-no-croak to origin
  • CI check enqueued (async)

CI

CI will be checked asynchronously.


Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/get-key-params-no-croak branch from 5cca67c to f0655eb Compare April 5, 2026 13:45
Copy link
Copy Markdown
Member

@timlegge timlegge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved comment change and MANIFEST update

@timlegge timlegge merged commit 68aadba into cpan-authors:main Apr 5, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants