feat(libSceLibreSsl): implement X509_STORE_add_cert #13285

Closed
JaceTheBlu wants to merge 43 commits from upstream-pr/13285 into main
JaceTheBlu commented 2026-10-30 11:48:04 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-30T11:48:04Z.


What

Implements X509_STORE_add_cert in libSceLibreSsl, on top of the X509 from #13266. This is stacked on #13266, and through it #11359 and #11129. Merge those first; this PR's own diff is then only the store change, its tests and its debt entry.

It follows LibreSSL 2.5.4 x509_lu.c:

  • It allocates a 16-byte X509_OBJECT and gives the certificate one more reference.
  • It looks up the subject in the object cache with sk_find. That lookup sorts the cache first, through the store's comparator: by type, then by canonical subject length, then by its bytes. So each new certificate is pushed after the sorted ones, and the next add sorts again.
  • A failed object allocation or push puts ERR_R_MALLOC_FAILURE from ERR_LIB_X509 on the queue. A failed push also drops the reference and frees the object.
  • A null certificate returns 0 with no error.

The comparator that X509_STORE_new installs no longer throws for certificates. X509_STORE_free now frees stored certificates with X509_free, as sk_X509_OBJECT_pop_free does.

There is a new entry in docs/dev/debt/libSceLibreSsl.md, and the pending count goes from 286 to 285.

Adding a certificate whose subject is already in the store throws, including adding the same certificate twice. LibreSSL then calls X509_cmp, which needs:

  • X509_check_purpose's SHA-1 hash and extension cache;
  • a DER encoder.

These cases also throw:

  • a subject marked modified, which LibreSSL re-encodes;
  • a stored CRL;
  • a null store or certificate info.

When it throws, the add first drops the reference it took and frees its object, so the certificate and the store are left as they were. The X509_STORE entry no longer says that stored certificates throw.

Tested

Debian container, GCC 14.2, full Release build of head ed7a8e090a: ctest -R 'libressl|crypto_memcmp' passes 38 of 38. tools/check_test_registration.py and python3 tools/check_conventions.py --base upstream/main pass.

  • guest_libressl_x509_store checks:

    • references;
    • the exact cache order after each add, including stack growth and an empty subject;
    • a certificate shared by two stores;
    • comparator results by type;
    • the throws listed above, with the reference counts and the cache unchanged after each one.
  • guest_libressl_x509_store_allocator checks three failures:

    • The object allocation fails.
    • The push's reallocation fails.
    • An add throws, which must free its object.

    It checks the error code, the reference count and what is freed, and that a later add succeeds.

  • guest_libressl_oracle (ANYPS5_LIBRESSL_ORACLE) now also fills a store on each side with 1 to 14 random certificates with distinct subjects, plus some null ones. After each add, it compares:

    • the return value and error queue;
    • the stack's count, allocation and sorted flag;
    • the order of the cached certificates;
    • every reference count, before and after X509_STORE_free.

    The 3,000 cases show no difference. The 6 AES_set_*_key cases are the existing ones described in the debt file.

Not tested on Windows, on a title or on a console.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: #13266, #11359, #11129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5083838947 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-10-30T11:48:04Z. --- ### What Implements `X509_STORE_add_cert` in libSceLibreSsl, on top of the `X509` from #13266. This is stacked on #13266, and through it #11359 and #11129. Merge those first; this PR's own diff is then only the store change, its tests and its debt entry. It follows LibreSSL 2.5.4 `x509_lu.c`: - It allocates a 16-byte `X509_OBJECT` and gives the certificate one more reference. - It looks up the subject in the object cache with `sk_find`. That lookup sorts the cache first, through the store's comparator: by type, then by canonical subject length, then by its bytes. So each new certificate is pushed after the sorted ones, and the next add sorts again. - A failed object allocation or push puts `ERR_R_MALLOC_FAILURE` from `ERR_LIB_X509` on the queue. A failed push also drops the reference and frees the object. - A null certificate returns 0 with no error. The comparator that `X509_STORE_new` installs no longer throws for certificates. `X509_STORE_free` now frees stored certificates with `X509_free`, as `sk_X509_OBJECT_pop_free` does. There is a new entry in `docs/dev/debt/libSceLibreSsl.md`, and the pending count goes from 286 to 285. Adding a certificate whose subject is already in the store throws, including adding the same certificate twice. LibreSSL then calls `X509_cmp`, which needs: - `X509_check_purpose`'s SHA-1 hash and extension cache; - a DER encoder. These cases also throw: - a subject marked modified, which LibreSSL re-encodes; - a stored CRL; - a null store or certificate info. When it throws, the add first drops the reference it took and frees its object, so the certificate and the store are left as they were. The `X509_STORE` entry no longer says that stored certificates throw. ### Tested Debian container, GCC 14.2, full Release build of head `ed7a8e090a`: `ctest -R 'libressl|crypto_memcmp'` passes 38 of 38. `tools/check_test_registration.py` and `python3 tools/check_conventions.py --base upstream/main` pass. - **`guest_libressl_x509_store`** checks: - references; - the exact cache order after each add, including stack growth and an empty subject; - a certificate shared by two stores; - comparator results by type; - the throws listed above, with the reference counts and the cache unchanged after each one. - **`guest_libressl_x509_store_allocator`** checks three failures: - The object allocation fails. - The push's reallocation fails. - An add throws, which must free its object. It checks the error code, the reference count and what is freed, and that a later add succeeds. - **`guest_libressl_oracle`** (`ANYPS5_LIBRESSL_ORACLE`) now also fills a store on each side with 1 to 14 random certificates with distinct subjects, plus some null ones. After each add, it compares: - the return value and error queue; - the stack's count, allocation and sorted flag; - the order of the cached certificates; - every reference count, before and after `X509_STORE_free`. The 3,000 cases show no difference. The 6 `AES_set_*_key` cases are the existing ones described in the debt file. Not tested on Windows, on a title or on a console. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: #13266, #11359, #11129 - [x] Fixes: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MarcZX10 commented 2026-10-30 11:52:46 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T11:52:46Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The duplicate-certificate and modified-subject error paths leak the candidate object and its added certificate reference, and the PR description does not use the required template.

What I ran

Reviewed head 25592c3e2a6db62703e28744073b56a03c784f33 against PR base 8e68a7d7b9f6aeedb0ca03eee115571640555988; the dependency checker confirmed #13266's current head is included in this PR. Its merge-preview result became stale while main advanced, so I do not rely on it. Environment: Debian 12 x86-64, Python 3.11.2, Git 2.39.5. No C++ build or tests were run locally.

git diff --check 8e68a7d7b9f6aeedb0ca03eee115571640555988...25592c3e2a6db62703e28744073b56a03c784f33
python3 tools/check_conventions.py --base 8e68a7d7b9f6aeedb0ca03eee115571640555988 --head 25592c3e2a6db62703e28744073b56a03c784f33 --title 'feat(libSceLibreSsl): implement X509_STORE_add_cert' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13285-25592c3e2a6d/pr-body.md
python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 8e68a7d7b9f6aeedb0ca03eee115571640555988 --head 25592c3e2a6db62703e28744073b56a03c784f33 --json
python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13285
python3 tools/pr_stack_check.py 13285 --repo boykopovar/AnyPS5 --output-dir /tmp/stack-13285

Results

Check Result
Diff whitespace Passed; git diff --check produced no output.
Conventions and PR template Failed: the required ### What, ### Tested, and ### Checklist headings are absent.
ABI audit passed_with_warnings; its two lexical findings are private helpers (CompareObjects, LoadFile), not exported functions. This is not a complete ABI or compile check.
Dependency/mergeability #13266's exact head is included. The current-main preview became stale because main advanced during the check; no conclusion is drawn from that preview.
Focused and oracle tests The author reports 38/38 `libressl
Hosted CI Intake, conventions, labels, eligibility, and progress report were queued at final refresh.
Unedited check output excerpts
(pull request): error: [pr-template] Fill in the pull request template: add the '### What' heading of the template
(pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template
(pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template
3 findings, 3 errors; GitHub shows at most 10 error annotations, the job summary lists all
{
  "status": "passed_with_warnings",
  "findings": [
    {
      "symbol": "CompareObjects",
      "kind": "public-declaration-not-found",
      "message": "No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface."
    },
    {
      "symbol": "LoadFile",
      "kind": "public-declaration-not-found",
      "message": "No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface."
    }
  ]
}

Findings

Blocking

  1. X509_STORE_add_cert_nid_postfix increments certificate->references and allocates object before Find. For duplicate subjects and modified subjects, Find throws through the documented unsupported paths; that bypasses both the decrement and free_nid_postfix(object). Each such call leaks the object and leaves the certificate reference count elevated. Clean up the candidate object and undo the reference increment on every exceptional exit (for example, use scoped ownership), then extend SameSubject to assert unchanged references after each thrown call.
  2. The PR description omits the repository-required template headings and checklist. Please preserve and fill in the template sections, including ### What, ### Tested, and ### Checklist with the declared dependencies. The repository's conventions check currently fails on these omissions.

Non-blocking

The implementation and test changes are extensive; I reviewed the store insertion path and the new duplicate/modified-subject cases that expose the resource leak. The author-reported test and oracle results have not been independently reproduced here.

Sources

Not verified

I did not build or run C++ tests or the LibreSSL oracle. Hosted CI was pending. The precheck's merge preview was stale after main advanced; ABI-audit warnings are lexical and need no public-export conclusion. I did not run the test-quality helper because it is absent from the isolated precheck checkout.

To get this to a good state

Please make the insertion path exception-safe, assert the reference counts remain unchanged after the expected throws, and update the description using the repository template. I will rerun the same diff, conventions, ABI, and dependency checks on the new head; build-dependent tests remain outside this initial no-build review.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5711839143 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5711839143). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T11:52:46Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The duplicate-certificate and modified-subject error paths leak the candidate object and its added certificate reference, and the PR description does not use the required template. ## What I ran Reviewed head `25592c3e2a6db62703e28744073b56a03c784f33` against PR base `8e68a7d7b9f6aeedb0ca03eee115571640555988`; the dependency checker confirmed #13266's current head is included in this PR. Its merge-preview result became stale while `main` advanced, so I do not rely on it. Environment: Debian 12 x86-64, Python 3.11.2, Git 2.39.5. No C++ build or tests were run locally. ```sh git diff --check 8e68a7d7b9f6aeedb0ca03eee115571640555988...25592c3e2a6db62703e28744073b56a03c784f33 python3 tools/check_conventions.py --base 8e68a7d7b9f6aeedb0ca03eee115571640555988 --head 25592c3e2a6db62703e28744073b56a03c784f33 --title 'feat(libSceLibreSsl): implement X509_STORE_add_cert' --body /tmp/anyps5-pr-precheck/boykopovar-AnyPS5-pr-13285-25592c3e2a6d/pr-body.md python3 tools/pr_abi_audit.py --repo /marc/AnyPS5 --base 8e68a7d7b9f6aeedb0ca03eee115571640555988 --head 25592c3e2a6db62703e28744073b56a03c784f33 --json python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13285 python3 tools/pr_stack_check.py 13285 --repo boykopovar/AnyPS5 --output-dir /tmp/stack-13285 ``` ## Results | Check | Result | |---|---| | Diff whitespace | Passed; `git diff --check` produced no output. | | Conventions and PR template | Failed: the required `### What`, `### Tested`, and `### Checklist` headings are absent. | | ABI audit | `passed_with_warnings`; its two lexical findings are private helpers (`CompareObjects`, `LoadFile`), not exported functions. This is not a complete ABI or compile check. | | Dependency/mergeability | #13266's exact head is included. The current-main preview became stale because `main` advanced during the check; no conclusion is drawn from that preview. | | Focused and oracle tests | The author reports 38/38 `libressl|crypto_memcmp` tests and 3,000 oracle cases passing on a full Release build; I did not run these. | | Hosted CI | Intake, conventions, labels, eligibility, and progress report were queued at final refresh. | <details> <summary>Unedited check output excerpts</summary> ```text (pull request): error: [pr-template] Fill in the pull request template: add the '### What' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Tested' heading of the template (pull request): error: [pr-template] Fill in the pull request template: add the '### Checklist' heading of the template 3 findings, 3 errors; GitHub shows at most 10 error annotations, the job summary lists all ``` ```json { "status": "passed_with_warnings", "findings": [ { "symbol": "CompareObjects", "kind": "public-declaration-not-found", "message": "No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface." }, { "symbol": "LoadFile", "kind": "public-declaration-not-found", "message": "No APS5_VABI declaration was found in a header; verify whether this is intentionally private or missing from the public interface." } ] } ``` </details> ## Findings ### Blocking 1. `X509_STORE_add_cert_nid_postfix` increments `certificate->references` and allocates `object` before `Find`. For duplicate subjects and modified subjects, `Find` throws through the documented unsupported paths; that bypasses both the decrement and `free_nid_postfix(object)`. Each such call leaks the object and leaves the certificate reference count elevated. Clean up the candidate object and undo the reference increment on every exceptional exit (for example, use scoped ownership), then extend `SameSubject` to assert unchanged references after each thrown call. 2. The PR description omits the repository-required template headings and checklist. Please preserve and fill in the template sections, including `### What`, `### Tested`, and `### Checklist` with the declared dependencies. The repository's conventions check currently fails on these omissions. ### Non-blocking The implementation and test changes are extensive; I reviewed the store insertion path and the new duplicate/modified-subject cases that expose the resource leak. The author-reported test and oracle results have not been independently reproduced here. ## Sources - [Insertion increments the reference before the throwing lookup](https://github.com/boykopovar/AnyPS5/blob/25592c3e2a6db62703e28744073b56a03c784f33/core/libs/prx/libSceLibreSsl/src/X509Store.cpp#L292-L309). - [Duplicate and modified-subject tests currently check only that an exception is thrown](https://github.com/boykopovar/AnyPS5/blob/25592c3e2a6db62703e28744073b56a03c784f33/core/libs/prx/libSceLibreSsl/tests/X509Store.cpp#L249-L260). - [Repository PR template and dependency checklist rules](https://github.com/boykopovar/AnyPS5/blob/99f7b51d2b49daa8f07fc822c51252ea704a46f0/CONTRIBUTING.md#L55-L70). ## Not verified I did not build or run C++ tests or the LibreSSL oracle. Hosted CI was pending. The precheck's merge preview was stale after `main` advanced; ABI-audit warnings are lexical and need no public-export conclusion. I did not run the test-quality helper because it is absent from the isolated precheck checkout. ## To get this to a good state Please make the insertion path exception-safe, assert the reference counts remain unchanged after the expected throws, and update the description using the repository template. I will rerun the same diff, conventions, ABI, and dependency checks on the new head; build-dependent tests remain outside this initial no-build review.
CnRJay commented 2026-11-01 20:01:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T20:01:06Z.

Review: COMMENTED


Correction (2026-11-01): the title-ID/log demand below is not a CONTRIBUTING requirement; Unblocks: none is allowed. The technical points below are unaffected.

1. Adapted third-party code is in-tree. core/libs/prx/libSceLibreSsl/src/X509Store.cpp opens with "Derived from LibreSSL 2.5.4 ... x509_lu.c, x509_vpm.c, by_file.c, x509_cmp.c, stack.c, obj_dat.c" followed by the full Eric Young licence text, and the description says the add "follows LibreSSL 2.5.4 x509_lu.c". CONTRIBUTING.md puts third-party code in a source-built submodule under 3rdparty/<name>, with only the guest ABI adapters in the library. The same request has already been made on the parent #13266 for src/X509.cpp; this file needs the same treatment, and it makes sense to settle the layout once for the stack rather than per PR.

2. No title reaches this. The checklist says "Unblocks: none" and the description says "Not tested on Windows, on a title or on a console". Please add a title ID with a log line showing a title on main reaching X509_STORE_add_cert (the NotImplemented line for it is enough), or state that none is known.

3. The common case still throws. Per the description, adding a certificate whose subject is already in the store throws, and that includes adding the same certificate twice. A title that loads a CA bundle with duplicate subjects (cross-signed roots are common) would hit that; can you say whether any title import path is expected to avoid it?

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5729960935 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5729960935). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-11-01T20:01:06Z. **Review:** COMMENTED --- **Correction (2026-11-01):** the title-ID/log demand below is not a CONTRIBUTING requirement; `Unblocks: none` is allowed. The technical points below are unaffected. **1. Adapted third-party code is in-tree.** `core/libs/prx/libSceLibreSsl/src/X509Store.cpp` opens with "Derived from LibreSSL 2.5.4 ... x509_lu.c, x509_vpm.c, by_file.c, x509_cmp.c, stack.c, obj_dat.c" followed by the full Eric Young licence text, and the description says the add "follows LibreSSL 2.5.4 `x509_lu.c`". CONTRIBUTING.md puts third-party code in a source-built submodule under `3rdparty/<name>`, with only the guest ABI adapters in the library. The same request has already been made on the parent #13266 for `src/X509.cpp`; this file needs the same treatment, and it makes sense to settle the layout once for the stack rather than per PR. **2. No title reaches this.** The checklist says "Unblocks: none" and the description says "Not tested on Windows, on a title or on a console". Please add a title ID with a log line showing a title on main reaching `X509_STORE_add_cert` (the NotImplemented line for it is enough), or state that none is known. **3. The common case still throws.** Per the description, adding a certificate whose subject is already in the store throws, and that includes adding the same certificate twice. A title that loads a CA bundle with duplicate subjects (cross-signed roots are common) would hit that; can you say whether any title import path is expected to avoid it?
MarcZX10 commented 2026-11-14 06:05:22 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T06:05:22Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: reject negative DER lengths before decoding.

What I ran

Reviewed head a528736c695012ba72091290edf221f7719a4f39 from the prepared diff and repository reader. No commands or tests were run; the reported build and test results are author supplied.

Results

Check Result Note
Diff and changed files passed All ten changed files read
Tests in this review not run Author reports 38 of 38 passing

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/X509.cpp:1863 accepts a negative length. It passes that value to ItemDecode; GetObject converts it to uint64_t at X509.cpp:887, then reads the DER header through the supplied input pointer. With a non-null pointer to an empty or undersized buffer, this can read out of bounds instead of rejecting the invalid length. Reject negative lengths before starting the decode and add a regression test.

Non-blocking

None.

Sources

  • The changed entry point and parser path are in X509.cpp lines 1863–1869 and 880–921.

Not verified

No tests were run during this review. Windows, title, and console behavior were not verified. The author reports those platforms were not tested. All changed files listed in the review manifest were read: CMakeLists.txt, Export.cpp, include/Api.hpp, src/X509.cpp, src/X509Store.cpp, tests/Oracle.cpp, tests/OracleReference.cpp, tests/X509.cpp, tests/X509Store.cpp, and docs/dev/debt/libSceLibreSsl.md. No changed files were excluded.

To get this to a good state

Reject negative d2i_X509 lengths and add a regression test for a negative length with a non-null input pointer; rerun the relevant tests on the new head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902134351 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5902134351). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T06:05:22Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: reject negative DER lengths before decoding. ## What I ran Reviewed head `a528736c695012ba72091290edf221f7719a4f39` from the prepared diff and repository reader. No commands or tests were run; the reported build and test results are author supplied. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All ten changed files read | | Tests in this review | not run | Author reports 38 of 38 passing | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/X509.cpp:1863` accepts a negative `length`. It passes that value to `ItemDecode`; `GetObject` converts it to `uint64_t` at `X509.cpp:887`, then reads the DER header through the supplied input pointer. With a non-null pointer to an empty or undersized buffer, this can read out of bounds instead of rejecting the invalid length. Reject negative lengths before starting the decode and add a regression test. ### Non-blocking None. ## Sources - The changed entry point and parser path are in `X509.cpp` lines 1863–1869 and 880–921. ## Not verified No tests were run during this review. Windows, title, and console behavior were not verified. The author reports those platforms were not tested. All changed files listed in the review manifest were read: `CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, `src/X509.cpp`, `src/X509Store.cpp`, `tests/Oracle.cpp`, `tests/OracleReference.cpp`, `tests/X509.cpp`, `tests/X509Store.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. No changed files were excluded. ## To get this to a good state Reject negative `d2i_X509` lengths and add a regression test for a negative length with a non-null input pointer; rerun the relevant tests on the new head.
MarcZX10 commented 2026-11-16 11:10:23 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-16T11:10:23Z.

Review: COMMENTED


Reviewed — no blocking findings

The inspected implementation at head f27b826502d2ab01205e20a2603e9371e7285d40 has no verified blocking defect; the description reports passing tests, but I did not run them.

What I ran

No commands or tests were run. I inspected the prepared diff and targeted source through repo_read.py.

Results

Check Result Note
Prepared diff inspection passed Reviewed relevant store changes
Tests not run Results in the description are author reported

Findings

Blocking

None verified in the inspected code.

Non-blocking

None.

Not verified

The full review is incomplete: I did not read all changed files, so an approval is not justified. The manifest indicates changes across multiple files; I inspected the description, commits, the start of the diff, and targeted ranges in X509Store.cpp. files.json was not available at the review path; exclusions and the complete set of reviewed files are not verified. Tests, Windows, title, and console behavior were not verified.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5919010070 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5919010070). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T11:10:23Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected implementation at head `f27b826502d2ab01205e20a2603e9371e7285d40` has no verified blocking defect; the description reports passing tests, but I did not run them. ## What I ran No commands or tests were run. I inspected the prepared diff and targeted source through `repo_read.py`. ## Results | Check | Result | Note | |---|---|---| | Prepared diff inspection | passed | Reviewed relevant store changes | | Tests | not run | Results in the description are author reported | ## Findings ### Blocking None verified in the inspected code. ### Non-blocking None. ## Not verified The full review is incomplete: I did not read all changed files, so an approval is not justified. The manifest indicates changes across multiple files; I inspected the description, commits, the start of the diff, and targeted ranges in `X509Store.cpp`. `files.json` was not available at the review path; exclusions and the complete set of reviewed files are not verified. Tests, Windows, title, and console behavior were not verified. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-17 09:26:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T09:26:27Z.

Review: COMMENTED


feat(libSceLibreSsl): implement X509_STORE_add_cert — no blocking findings

Nothing blocks this; the points below are optional. The review is partial (see Not verified), so this is a comment, not an approval.

What I ran

  • Read description.md, commits.md, manifest.json and the first 995 lines of diff.patch (CMake, Export.cpp, include/Api.hpp, the start of src/X509.cpp).
  • Read diff.patch lines 2030–2075 (d2i_X509, X509_free, CertInfo) and 2076–2355 (src/X509Store.cpp: comparator, Sort/Find, FreeObject, X509_STORE_free, X509_STORE_add_cert).
  • repo_read.py search for uses of the renamed enc field and for the X509_free and d2i_X509 definitions. Both searches returned 0 matching lines, so they checked nothing.
  • No build and no test run. The description reports ctest -R 'libressl|crypto_memcmp' at 38/38 on head 41809f501b; I did not reproduce it.

Results

Check Result Note
Build and ctest Not run Description reports a pass; not reproduced here.
Logic read: X509_STORE_add_cert Read src/X509Store.cpp:2322–2350 (diff). Reference is taken before the lookup and dropped on every failure path. Null certificate returns 0 with no error.
Logic read: comparator and Find Read src/X509Store.cpp:2231–2294 (diff). Duplicate subjects throw, as the description says.
Store free Read src/X509Store.cpp:2305–2315 (diff). Stored certificates are released with X509_free.
d2i_X509 / X509_free Read in part src/X509.cpp:2059–2071 (diff). The body of the decoder was not read.
Rename of LibreSslX509CertInfo::enc to encoding Not checked Search returned no matches; callers not verified.
Test files Not read tests/X509.cpp, tests/X509Store.cpp, tests/Oracle.cpp, tests/OracleReference.cpp.
Debt entry Not read docs/dev/debt/libSceLibreSsl.md, hunks at lines 128, 157 and 173. The "286 to 285" count is not verified.

Findings

Blocking

None found in the code I read.

Non-blocking

None recorded. I did not find a concrete defect in the sections I read.

Not verified

  • Build, ctest, and the 3,000-case oracle run. None were run here.
  • src/X509.cpp from diff line 995 to the end of the new file (about 1,900 lines in total) and the decoder body in src/X509.cpp around the d2i_X509 call.
  • The enc to encoding rename in include/Api.hpp and all its callers in the library. The reader search returned no matches, so this was not checked.
  • The static_assert offsets in src/X509.cpp for the new 176-byte LibreSslX509 layout. They were not checked against the header.
  • The four test files and the debt entry (listed above).
  • files.json was not read, so I cannot say which files it lists as reviewed.

To get this to a good state

Nothing is required.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5935900328 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5935900328). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T09:26:27Z. **Review:** COMMENTED --- # feat(libSceLibreSsl): implement X509_STORE_add_cert — no blocking findings Nothing blocks this; the points below are optional. The review is partial (see **Not verified**), so this is a comment, not an approval. ## What I ran - Read `description.md`, `commits.md`, `manifest.json` and the first 995 lines of `diff.patch` (CMake, `Export.cpp`, `include/Api.hpp`, the start of `src/X509.cpp`). - Read `diff.patch` lines 2030–2075 (`d2i_X509`, `X509_free`, `CertInfo`) and 2076–2355 (`src/X509Store.cpp`: comparator, `Sort`/`Find`, `FreeObject`, `X509_STORE_free`, `X509_STORE_add_cert`). - `repo_read.py search` for uses of the renamed `enc` field and for the `X509_free` and `d2i_X509` definitions. Both searches returned 0 matching lines, so they checked nothing. - No build and no test run. The description reports `ctest -R 'libressl|crypto_memcmp'` at 38/38 on head `41809f501b`; I did not reproduce it. ## Results | Check | Result | Note | | --- | --- | --- | | Build and `ctest` | Not run | Description reports a pass; not reproduced here. | | Logic read: `X509_STORE_add_cert` | Read | `src/X509Store.cpp:2322–2350` (diff). Reference is taken before the lookup and dropped on every failure path. Null certificate returns 0 with no error. | | Logic read: comparator and `Find` | Read | `src/X509Store.cpp:2231–2294` (diff). Duplicate subjects throw, as the description says. | | Store free | Read | `src/X509Store.cpp:2305–2315` (diff). Stored certificates are released with `X509_free`. | | `d2i_X509` / `X509_free` | Read in part | `src/X509.cpp:2059–2071` (diff). The body of the decoder was not read. | | Rename of `LibreSslX509CertInfo::enc` to `encoding` | Not checked | Search returned no matches; callers not verified. | | Test files | Not read | `tests/X509.cpp`, `tests/X509Store.cpp`, `tests/Oracle.cpp`, `tests/OracleReference.cpp`. | | Debt entry | Not read | `docs/dev/debt/libSceLibreSsl.md`, hunks at lines 128, 157 and 173. The "286 to 285" count is not verified. | ## Findings ### Blocking None found in the code I read. ### Non-blocking None recorded. I did not find a concrete defect in the sections I read. ## Not verified - Build, `ctest`, and the 3,000-case oracle run. None were run here. - `src/X509.cpp` from diff line 995 to the end of the new file (about 1,900 lines in total) and the decoder body in `src/X509.cpp` around the `d2i_X509` call. - The `enc` to `encoding` rename in `include/Api.hpp` and all its callers in the library. The reader search returned no matches, so this was not checked. - The `static_assert` offsets in `src/X509.cpp` for the new 176-byte `LibreSslX509` layout. They were not checked against the header. - The four test files and the debt entry (listed above). - `files.json` was not read, so I cannot say which files it lists as `reviewed`. ## To get this to a good state Nothing is required.
MarcZX10 commented 2026-11-18 13:31:11 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-18T13:31:11Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: reject oversized DER lengths before narrowing them to int.

What I ran

Reviewed head 0ecf9daf7de09ff04cdd0a826f559eeda44c78bc using the prepared diff and repo_read.py source reader. No tests or build commands were run. The description reports a Debian/GCC 14.2 test run; that result was not independently run here.

Results

Check Result Note
Source review failed Oversized DER length can be narrowed
Tests/build not run Author reports passing tests

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/X509.cpp:1247: PrimitiveDecode narrows the decoded content length from int64_t to int without checking that it fits. A valid encoded length above INT_MAX can wrap or truncate, causing ContentToValue to process a length different from the encoded content length and potentially read past the input buffer. Reject values above INT_MAX before this cast (and preserve the matching error behavior).

Non-blocking

None.

Not verified

  • The reported test suite and build were not run during this review.
  • Windows, title, and console behavior were not tested, as the author also notes.
  • Read all changed files listed in the manifest: core/libs/prx/libSceLibreSsl/CMakeLists.txt, core/libs/prx/libSceLibreSsl/Export.cpp, core/libs/prx/libSceLibreSsl/include/Api.hpp, core/libs/prx/libSceLibreSsl/src/X509.cpp, core/libs/prx/libSceLibreSsl/src/X509Store.cpp, core/libs/prx/libSceLibreSsl/tests/Oracle.cpp, core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp, core/libs/prx/libSceLibreSsl/tests/X509.cpp, core/libs/prx/libSceLibreSsl/tests/X509Store.cpp, and docs/dev/debt/libSceLibreSsl.md. No files were excluded by the prepared manifest.

To get this to a good state

Reject DER content lengths that cannot be represented by int before casting, add coverage for that boundary, and rerun the reported build and test checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5957587003 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13285#pullrequestreview-5957587003). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-18T13:31:11Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: reject oversized DER lengths before narrowing them to `int`. ## What I ran Reviewed head `0ecf9daf7de09ff04cdd0a826f559eeda44c78bc` using the prepared diff and `repo_read.py` source reader. No tests or build commands were run. The description reports a Debian/GCC 14.2 test run; that result was not independently run here. ## Results | Check | Result | Note | |---|---|---| | Source review | failed | Oversized DER length can be narrowed | | Tests/build | not run | Author reports passing tests | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/X509.cpp:1247`: `PrimitiveDecode` narrows the decoded content length from `int64_t` to `int` without checking that it fits. A valid encoded length above `INT_MAX` can wrap or truncate, causing `ContentToValue` to process a length different from the encoded content length and potentially read past the input buffer. Reject values above `INT_MAX` before this cast (and preserve the matching error behavior). ### Non-blocking None. ## Not verified - The reported test suite and build were not run during this review. - Windows, title, and console behavior were not tested, as the author also notes. - Read all changed files listed in the manifest: `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `core/libs/prx/libSceLibreSsl/Export.cpp`, `core/libs/prx/libSceLibreSsl/include/Api.hpp`, `core/libs/prx/libSceLibreSsl/src/X509.cpp`, `core/libs/prx/libSceLibreSsl/src/X509Store.cpp`, `core/libs/prx/libSceLibreSsl/tests/Oracle.cpp`, `core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp`, `core/libs/prx/libSceLibreSsl/tests/X509.cpp`, `core/libs/prx/libSceLibreSsl/tests/X509Store.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. No files were excluded by the prepared manifest. ## To get this to a good state Reject DER content lengths that cannot be represented by `int` before casting, add coverage for that boundary, and rerun the reported build and test checks on the updated head.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5!13285
No description provided.