Skip to content

Fix correctness findings from penpal testing#3235

Open
prasden wants to merge 9 commits into
aws:mainfrom
prasden:penpal-correctness-fixes
Open

Fix correctness findings from penpal testing#3235
prasden wants to merge 9 commits into
aws:mainfrom
prasden:penpal-correctness-fixes

Conversation

@prasden
Copy link
Copy Markdown
Contributor

@prasden prasden commented May 8, 2026

Issues:

Addresses: P409219367

Description of changes:

This PR adds a small series of correctness fixes brought up by Penpal testing:

  • BIO_write_ex returned early on NULL bio without initializing *written_bytes in bio.c. We now initialize written_bytes to 0 before the NULL check so the caller receives that 0 bytes were written if any checks fail.

  • NCONF_load_bio had a signed overflow in bufnum in conf.c. We now guard against overflow before the addition.

  • BN_le2bn did not reset the sign flag when reusing an existing BIGNUM in bytes.c. We now clear it to avoid staleness.

  • PEM_write_bio previously used an int loop counter in pem_lib.c. We now use long to match the input length type and prevent overflow.

  • crl_cb in x_crl.c did not free idp/akid on error paths. We now free and NULL them before returning to prevent leaks

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.

@prasden prasden requested a review from a team as a code owner May 8, 2026 19:43
@prasden prasden changed the title Fix correctness issues from penpal issues Fix correctness findings from penpal testing May 8, 2026
samuel40791765
samuel40791765 previously approved these changes May 8, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

clang-tidy made some suggestions

Comment thread crypto/pem/pem_lib.c Outdated
Comment thread crypto/pem/pem_lib.c Outdated
Comment thread crypto/pem/pem_lib.c Outdated
Comment thread crypto/pem/pem_lib.c Outdated
Comment thread crypto/pem/pem_lib.c Outdated
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 8, 2026

Codecov Report

❌ Patch coverage is 33.33333% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.37%. Comparing base (c025a91) to head (3fe1789).

Files with missing lines Patch % Lines
crypto/x509/x_crl.c 0.00% 8 Missing ⚠️
crypto/conf/conf.c 33.33% 2 Missing ⚠️
crypto/pem/pem_lib.c 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3235      +/-   ##
==========================================
+ Coverage   78.14%   78.37%   +0.22%     
==========================================
  Files         689      689              
  Lines      123334   123352      +18     
  Branches    17172    17178       +6     
==========================================
+ Hits        96384    96672     +288     
+ Misses      26037    25768     -269     
+ Partials      913      912       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread crypto/pem/pem_lib.c Outdated
Comment thread crypto/bio/bio.c
if (written_bytes != NULL) {
*written_bytes = 0;
}
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this still needed if we call it earlier in the function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It was redundant, removed.

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.

4 participants