Skip to content

x509-cert: Fix underflow on empty input in Certificate::load_pem_chain#1965

Merged
tarcieri merged 1 commit into
RustCrypto:masterfrom
lukevalenta:lvalenta/x509-cert-fix-underflow
Jul 26, 2025
Merged

x509-cert: Fix underflow on empty input in Certificate::load_pem_chain#1965
tarcieri merged 1 commit into
RustCrypto:masterfrom
lukevalenta:lvalenta/x509-cert-fix-underflow

Conversation

@lukevalenta

Copy link
Copy Markdown
Contributor

input.len() - 1 (a usize) underflows when the input is empty.

@tarcieri tarcieri merged commit 6e6ed03 into RustCrypto:master Jul 26, 2025
54 checks passed
MarkAtwood added a commit to MarkAtwood/crate-pkix that referenced this pull request May 11, 2026
The x509-cert empty-input panic was fixed upstream in RustCrypto/formats#1965
(commit 6e6ed032, merged 2025-07-26) and shipped in x509-cert 0.3.0-rc.2 and
later. It is not in any 0.2.x stable release, so the workaround stays in place
while the workspace pins x509-cert = "0.2". Update the comment so future
maintainers know the removal trigger is a 0.3.x stable bump, not an
unscheduled future event.

Closes PKIX-wzmg. Follow-up: PKIX-rb6n tracks the actual workaround removal.
MarkAtwood added a commit to MarkAtwood/crate-pkix that referenced this pull request Jun 5, 2026
The x509-cert empty-input panic was fixed upstream in RustCrypto/formats#1965
(commit 6e6ed032, merged 2025-07-26) and shipped in x509-cert 0.3.0-rc.2 and
later. It is not in any 0.2.x stable release, so the workaround stays in place
while the workspace pins x509-cert = "0.2". Update the comment so future
maintainers know the removal trigger is a 0.3.x stable bump, not an
unscheduled future event.

Closes PKIX-wzmg. Follow-up: PKIX-rb6n tracks the actual workaround removal.
baloo added a commit to baloo/formats that referenced this pull request Jul 6, 2026
Added

- Serial number generator ([RustCrypto#1270])
- `DecodeValue` for `x509_cert::time::Time` ([RustCrypto#1986])
- `FromStr` for `x509_cert::time::Time` ([RustCrypto#1961])
- impl `Hash` for `Name` ([RustCrypto#1764])
- impl `Ord` for `CrlReason` ([RustCrypto#1869])
- `DirectoryString::BmpString` ([RustCrypto#1794])
- `Crl` builder ([RustCrypto#1759])
- `Time::now` method ([RustCrypto#1761])
- `Validity::infinity` helper ([RustCrypto#1528])
- `Validity::new` method ([RustCrypto#1529])
- Re-export `spki` types without `*Owned` suffixes ([RustCrypto#1534])
- `x509_cert::builder::AsyncBuilder` using `AsyncSigner` ([RustCrypto#1280])

Changed

- Decompose `AsExtension` into `Criticality + AsExtension` ([RustCrypto#2109])
- Improve extension API flexibility and ergonomics ([RustCrypto#2120])
- Expose `Profile` in the `CrlBuilder` ([RustCrypto#1870])
- Ensure a serial number can be stored in a database ([RustCrypto#1868])
- Move the CSR builder `x509_cert::request` ([RustCrypto#1581])
- Rename `x509_cert::builder::Profile` to `BuilderProfile` ([RustCrypto#1514] && [RustCrypto#1517])
- `Name` is now a new type over `RdnSequence` ([RustCrypto#1499])
- make `RelativeDistinguishedName` fields private ([RustCrypto#1510])
- make `RdnSequence` fields private ([RustCrypto#1508])
- make (Tbs)`CertificateInner` fields private ([RustCrypto#1505])
- rename helpers to `get_extension`/`filter_extensions` ([RustCrypto#1497])
- `check_name_encoding` now allow extraneous components ([RustCrypto#1447])
- Accept RFC-invalid certificates as TrustAnchors ([RustCrypto#1403])

- Edition changed to 2024 and MSRV bumped to 1.85 ([RustCrypto#1689])
- Bump `rand` to `v0.10` ([RustCrypto#2212])
- Bump `der` to `v0.8` ([RustCrypto#2234])
- Bump `digest` to `v0.11` ([RustCrypto#2237])
- Bump `sha2` to `v0.11` ([RustCrypto#2273])
- Bump `spki` to `v0.8` ([RustCrypto#2277])
- Bump `signature` to `v3` ([RustCrypto#2326])

Fixed

- Converting from `SystemTime` should use `UtcTime` if date <= 2049 ([RustCrypto#1969])
- Underflow on empty input in `Certificate::load_pem_chain` ([RustCrypto#1965])
- Domain validated should accept CNs ([RustCrypto#1815])
- Serialization of email addresses ([RustCrypto#1425])

Removed

- Std requirement for `x509_cert::builder` ([RustCrypto#1709])
- `RelativeDistinguishedName::encode_from_string` ([RustCrypto#1509])

[RustCrypto#1270]: RustCrypto#1270
[RustCrypto#1280]: RustCrypto#1280
[RustCrypto#1403]: RustCrypto#1403
[RustCrypto#1425]: RustCrypto#1425
[RustCrypto#1447]: RustCrypto#1447
[RustCrypto#1497]: RustCrypto#1497
[RustCrypto#1499]: RustCrypto#1499
[RustCrypto#1505]: RustCrypto#1505
[RustCrypto#1508]: RustCrypto#1508
[RustCrypto#1509]: RustCrypto#1509
[RustCrypto#1510]: RustCrypto#1510
[RustCrypto#1514]: RustCrypto#1514
[RustCrypto#1517]: RustCrypto#1517
[RustCrypto#1528]: RustCrypto#1528
[RustCrypto#1529]: RustCrypto#1529
[RustCrypto#1534]: RustCrypto#1534
[RustCrypto#1581]: RustCrypto#1581
[RustCrypto#1689]: RustCrypto#1689
[RustCrypto#1709]: RustCrypto#1709
[RustCrypto#1759]: RustCrypto#1759
[RustCrypto#1761]: RustCrypto#1761
[RustCrypto#1764]: RustCrypto#1764
[RustCrypto#1794]: RustCrypto#1794
[RustCrypto#1815]: RustCrypto#1815
[RustCrypto#1868]: RustCrypto#1868
[RustCrypto#1869]: RustCrypto#1869
[RustCrypto#1870]: RustCrypto#1870
[RustCrypto#1961]: RustCrypto#1961
[RustCrypto#1965]: RustCrypto#1965
[RustCrypto#1969]: RustCrypto#1969
[RustCrypto#1986]: RustCrypto#1986
[RustCrypto#2109]: RustCrypto#2109
[RustCrypto#2120]: RustCrypto#2120
[RustCrypto#2212]: RustCrypto#2212
[RustCrypto#2234]: RustCrypto#2234
[RustCrypto#2237]: RustCrypto#2237
[RustCrypto#2273]: RustCrypto#2273
[RustCrypto#2277]: RustCrypto#2277
[RustCrypto#2326]: RustCrypto#2326
@baloo baloo mentioned this pull request Jul 6, 2026
baloo added a commit to baloo/formats that referenced this pull request Jul 6, 2026
Added

- Serial number generator ([RustCrypto#1270])
- `DecodeValue` for `x509_cert::time::Time` ([RustCrypto#1986])
- `FromStr` for `x509_cert::time::Time` ([RustCrypto#1961])
- impl `Hash` for `Name` ([RustCrypto#1764])
- impl `Ord` for `CrlReason` ([RustCrypto#1869])
- `DirectoryString::BmpString` ([RustCrypto#1794])
- `Crl` builder ([RustCrypto#1759])
- `Time::now` method ([RustCrypto#1761])
- `Validity::infinity` helper ([RustCrypto#1528])
- `Validity::new` method ([RustCrypto#1529])
- Re-export `spki` types without `*Owned` suffixes ([RustCrypto#1534])
- `x509_cert::builder::AsyncBuilder` using `AsyncSigner` ([RustCrypto#1280])

Changed

- Decompose `AsExtension` into `Criticality + AsExtension` ([RustCrypto#2109])
- Improve extension API flexibility and ergonomics ([RustCrypto#2120])
- Expose `Profile` in the `CrlBuilder` ([RustCrypto#1870])
- Ensure a serial number can be stored in a database ([RustCrypto#1868])
- Move the CSR builder `x509_cert::request` ([RustCrypto#1581])
- Rename `x509_cert::builder::Profile` to `BuilderProfile` ([RustCrypto#1514] && [RustCrypto#1517])
- `Name` is now a new type over `RdnSequence` ([RustCrypto#1499])
- make `RelativeDistinguishedName` fields private ([RustCrypto#1510])
- make `RdnSequence` fields private ([RustCrypto#1508])
- make (Tbs)`CertificateInner` fields private ([RustCrypto#1505])
- rename helpers to `get_extension`/`filter_extensions` ([RustCrypto#1497])
- `check_name_encoding` now allow extraneous components ([RustCrypto#1447])
- Accept RFC-invalid certificates as TrustAnchors ([RustCrypto#1403])

- Edition changed to 2024 and MSRV bumped to 1.85 ([RustCrypto#1689])
- Bump `rand` to `v0.10` ([RustCrypto#2212])
- Bump `der` to `v0.8` ([RustCrypto#2234])
- Bump `digest` to `v0.11` ([RustCrypto#2237])
- Bump `sha2` to `v0.11` ([RustCrypto#2273])
- Bump `spki` to `v0.8` ([RustCrypto#2277])
- Bump `signature` to `v3` ([RustCrypto#2326])

Fixed

- Converting from `SystemTime` should use `UtcTime` if date <= 2049 ([RustCrypto#1969])
- Underflow on empty input in `Certificate::load_pem_chain` ([RustCrypto#1965])
- Domain validated should accept CNs ([RustCrypto#1815])
- Serialization of email addresses ([RustCrypto#1425])

Removed

- Std requirement for `x509_cert::builder` ([RustCrypto#1709])
- `RelativeDistinguishedName::encode_from_string` ([RustCrypto#1509])

[RustCrypto#1270]: RustCrypto#1270
[RustCrypto#1280]: RustCrypto#1280
[RustCrypto#1403]: RustCrypto#1403
[RustCrypto#1425]: RustCrypto#1425
[RustCrypto#1447]: RustCrypto#1447
[RustCrypto#1497]: RustCrypto#1497
[RustCrypto#1499]: RustCrypto#1499
[RustCrypto#1505]: RustCrypto#1505
[RustCrypto#1508]: RustCrypto#1508
[RustCrypto#1509]: RustCrypto#1509
[RustCrypto#1510]: RustCrypto#1510
[RustCrypto#1514]: RustCrypto#1514
[RustCrypto#1517]: RustCrypto#1517
[RustCrypto#1528]: RustCrypto#1528
[RustCrypto#1529]: RustCrypto#1529
[RustCrypto#1534]: RustCrypto#1534
[RustCrypto#1581]: RustCrypto#1581
[RustCrypto#1689]: RustCrypto#1689
[RustCrypto#1709]: RustCrypto#1709
[RustCrypto#1759]: RustCrypto#1759
[RustCrypto#1761]: RustCrypto#1761
[RustCrypto#1764]: RustCrypto#1764
[RustCrypto#1794]: RustCrypto#1794
[RustCrypto#1815]: RustCrypto#1815
[RustCrypto#1868]: RustCrypto#1868
[RustCrypto#1869]: RustCrypto#1869
[RustCrypto#1870]: RustCrypto#1870
[RustCrypto#1961]: RustCrypto#1961
[RustCrypto#1965]: RustCrypto#1965
[RustCrypto#1969]: RustCrypto#1969
[RustCrypto#1986]: RustCrypto#1986
[RustCrypto#2109]: RustCrypto#2109
[RustCrypto#2120]: RustCrypto#2120
[RustCrypto#2212]: RustCrypto#2212
[RustCrypto#2234]: RustCrypto#2234
[RustCrypto#2237]: RustCrypto#2237
[RustCrypto#2273]: RustCrypto#2273
[RustCrypto#2277]: RustCrypto#2277
[RustCrypto#2326]: RustCrypto#2326
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