Skip to content

fix: thread-safe digest buffer in get_message_digest()#1

Draft
Koan-Bot wants to merge 71 commits into
masterfrom
koan.atoomic/fix-digest-static-buffer
Draft

fix: thread-safe digest buffer in get_message_digest()#1
Koan-Bot wants to merge 71 commits into
masterfrom
koan.atoomic/fix-digest-static-buffer

Conversation

@Koan-Bot
Copy link
Copy Markdown
Collaborator

What

Replace the static buffer in get_message_digest() with caller-provided stack buffers.

Why

static unsigned char m[EVP_MAX_MD_SIZE] is shared across all calls — a data race
in threaded Perl builds (ithreads / multiplicity). Two concurrent sign() or verify()
calls would silently corrupt each other's digest.

How

Changed get_message_digest() to accept an unsigned char* md parameter instead of
owning a static buffer. Each caller (sign(), verify()) now declares its own
digest_buf[EVP_MAX_MD_SIZE] on the stack — zero shared state, zero heap allocation.

Testing

make test — 281 tests pass on Perl 5.42.0 / OpenSSL 3.6.1 (macOS).

🤖 Generated with Claude Code

atoomic and others added 30 commits June 12, 2024 21:48
- opened: pull request is created
- synchronize: commit(s) pushed to the pull request
- reopened: closed pull request is reopened
- edited: title, body, or the base branch of the PR is modified
- ready_for_review: pull request is taken out from draft mode
AutoLoader serves no purpose for this module and adds complexity.
Fix issue when libz is not linked on AIX
Fixes cpan-authors#50 - Correct openssl version may not be found
toddr and others added 30 commits October 29, 2025 16:09
Don't ignore the set padding return code
sha1 is problematic especially since RedHat disabled it's usage
Also add t/padding.t that attempts to test the paddingi
combinations more thoroughly or possible more clearly?
Clarify the padding and fix some missing frees for openssl objects
Add blurb about JWTs for padding changes
Change the default hash mode to sha256
As it is not supported any more and thus apt-get is failing
See also: https://www.debian.org/releases/buster/
It will send PRs when newer versions of github actions are released.
And protect them using if-statements
Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 6.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v6)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…b_actions/actions/checkout-6

Bump actions/checkout from 4 to 6
Separate the apt-get and the yum steps in the CI
- META_MERGE resources: http:// → https:// (license, homepage, repository)
- META_MERGE build_requires: 'Test' → 'Test::More' (all tests use Test::More)
- .gitignore: remove duplicate *.gcov and *.gcno entries
- CI: add debian:trixie to OpenSSL matrix (3.4.x coverage)
- CI: simplify apt-get condition with startsWith('debian:')

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
chore: fix META URLs, gitignore dupes, build_requires, add trixie CI
EVP_PKEY_CTX allocated by EVP_PKEY_CTX_new_from_pkey() was never freed,
leaking memory on every check_key() call. Also add a NULL check on the
context allocation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…k-key-ctx-leak

fix: check_key() EVP_PKEY_CTX leak on OpenSSL 3.x
Don't include whrlpool.h if whirlpool is disabled
The static buffer `unsigned char m[EVP_MAX_MD_SIZE]` at file scope meant
all calls shared the same memory — a data race in threaded Perl (ithread
or multiplicity builds).

Change the function to accept a caller-provided buffer instead. Each call
site now declares its own stack-local `digest_buf[EVP_MAX_MD_SIZE]`,
eliminating the shared mutable state without any heap allocation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

7 participants