Skip to content

pki: check pem.Decode returned nil block. - #607

Merged
armfazh merged 1 commit into
cloudflare:mainfrom
z9z:fix/pki-pem-decode-nil-block
May 7, 2026
Merged

pki: check pem.Decode returned nil block.#607
armfazh merged 1 commit into
cloudflare:mainfrom
z9z:fix/pki-pem-decode-nil-block

Conversation

@z9z

@z9z z9z commented May 7, 2026

Copy link
Copy Markdown
Contributor

UnmarshalPEMPublicKey and UnmarshalPEMPrivateKey panic with a nil pointer dereference when given input that is not a valid PEM block (pem.Decode returns nil for the block). Add a nil check before dereferencing block.Type.
Test added with empty/garbage input.

@armfazh
armfazh merged commit becaf2f into cloudflare:main May 7, 2026
12 checks passed
@armfazh

armfazh commented May 7, 2026

Copy link
Copy Markdown
Contributor

Thanks @z9z

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