Skip to content

UPSTREAM PR #30914: pkcs7: Fix negative index handling in PKCS7_get_issuer_and_serial#676

Open
loci-dev wants to merge 1 commit into
mainfrom
loci/pr-30914-issue-30910-pkcs7-negative-index
Open

UPSTREAM PR #30914: pkcs7: Fix negative index handling in PKCS7_get_issuer_and_serial#676
loci-dev wants to merge 1 commit into
mainfrom
loci/pr-30914-issue-30910-pkcs7-negative-index

Conversation

@loci-dev
Copy link
Copy Markdown

Note

Source pull request: openssl/openssl#30914

PKCS7_get_issuer_and_serial checked only the upper bound of the recipient-info index. A negative idx could therefore reach sk_PKCS7_RECIP_INFO_value, return NULL and then be dereferenced.

Reject negative indices explicitly and return NULL, matching the existing out-of-range behavior for indices greater than or equal to the recipient-info stack size.

A regression test is added for idx == -1, while also checking that idx == 0 still returns the expected issuer-and-serial value.

Fixes #30910.

The PR commit applies cleanly to master and all four upstream branches openssl-3.4, openssl-3.5, openssl-3.6 and openssl-4.0.

Reject negative indices before looking up the recipient info stack entry. This makes negative out-of-range indices match the existing behavior for too-large positive indices and avoids dereferencing a NULL recipient info.

Add a regression test for the negative index case.

Fixes #30910
@loci-review
Copy link
Copy Markdown

loci-review Bot commented Apr 21, 2026

No meaningful performance changes were detected across 20082 analyzed functions in the following binaries: libcrypto.so, libssl.so, openssl.

💬 Questions? Tag @loci-dev

@loci-dev loci-dev force-pushed the main branch 5 times, most recently from 421b135 to 770bf14 Compare April 28, 2026 03:44
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