Skip to content

fix: null-check cert_and_key fields in load helpers#5932

Open
jouho wants to merge 4 commits into
aws:mainfrom
jouho:fix/cert-chain-key-helpers-null-check
Open

fix: null-check cert_and_key fields in load helpers#5932
jouho wants to merge 4 commits into
aws:mainfrom
jouho:fix/cert-chain-key-helpers-null-check

Conversation

@jouho

@jouho jouho commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Goal

Add null-checks on cert_and_key and the field being dereferenced in s2n_cert_chain_and_key_set_cert_chain_from_stuffer and s2n_cert_chain_and_key_set_private_key_from_stuffer.

Why

Both helpers dereference cert_and_key->cert_chain / cert_and_key->private_key without any guard, while their peers s2n_cert_chain_and_key_load_sans and _load_cns lead with POSIX_ENSURE_REF on the field they use.

How

Add POSIX_ENSURE_REF(cert_and_key) and the field-specific POSIX_ENSURE_REF at the top of both helpers, matching the pattern used by the san/cn load functions.

Testing

All tests pass.

Related

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

@github-actions github-actions Bot added the s2n-core team label Jun 12, 2026
@jouho jouho marked this pull request as ready for review June 12, 2026 21:59
@jouho jouho requested review from CarolYeh910 and jmayclin June 12, 2026 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant