Skip to content

[3.10] gh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH-100373) - #153312

Merged
pablogsal merged 2 commits into
python:3.10from
miss-islington:backport-acfe02f-3.10
Aug 10, 2026
Merged

[3.10] gh-100372: Use BIO_eof to detect EOF for SSL_FILETYPE_ASN1 (GH-100373)#153312
pablogsal merged 2 commits into
python:3.10from
miss-islington:backport-acfe02f-3.10

Conversation

@miss-islington

@miss-islington miss-islington commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

In PEM, we need to parse until error and then suppress PEM_R_NO_START_LINE, because PEM allows arbitrary leading and trailing data. DER, however, does not. Parsing until error and suppressing ASN1_R_HEADER_TOO_LONG doesn't quite work because that error also covers some cases that should be rejected.

Instead, check BIO_eof early and stop the loop that way.
(cherry picked from commit acfe02f)

Co-authored-by: David Benjamin davidben@google.com
Automerge-Triggered-By: GH:Yhg1s

…honGH-100373)

In PEM, we need to parse until error and then suppress `PEM_R_NO_START_LINE`, because PEM allows arbitrary leading and trailing data. DER, however, does not. Parsing until error and suppressing `ASN1_R_HEADER_TOO_LONG` doesn't quite work because that error also covers some cases that should be rejected.

Instead, check `BIO_eof` early and stop the loop that way.
(cherry picked from commit acfe02f)

Co-authored-by: David Benjamin <davidben@google.com>
Automerge-Triggered-By: GH:Yhg1s

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@encukou: Why did you mark the PR as a draft? IMO we should apply this fix to Python 3.10 (the macOS CI is failing).

@encukou

encukou commented Aug 10, 2026

Copy link
Copy Markdown
Member

@encukou: Why did you mark the PR as a draft? IMO we should apply this fix to Python 3.10 (the macOS CI is failing).

Same reason as on the 3.11 one.

@encukou
encukou marked this pull request as ready for review August 10, 2026 07:52
@pablogsal
pablogsal merged commit 129667d into python:3.10 Aug 10, 2026
17 checks passed
@miss-islington
miss-islington deleted the backport-acfe02f-3.10 branch August 10, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

6 participants