feat(libSceLibreSsl): implement d2i_X509 and X509_free #13266

Open
JaceTheBlu wants to merge 31 commits from upstream-pr/13266 into main
JaceTheBlu commented 2026-10-30 10:28:57 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by JaceTheBlu on 2026-10-30T10:28:57Z.


What

Implements d2i_X509 and X509_free in libSceLibreSsl. This is stacked on #11359, and through it #11129. Merge those first; this PR's own diff is then only the decoder, its tests and its debt entry.

src/X509.cpp ports the LibreSSL 2.5.4 template decoder (tasn_dec.c, tasn_new.c, tasn_fre.c), limited to the items an X509 holds:

  • the certificate and X509_CINF, which keeps the encoding of the signed part;
  • algorithms with an ASN1_TYPE parameter;
  • names, through the x_name.c extern functions: the DER cache, entries with their RDN index, and the canonical encoding;
  • validity, the public key (left encoded) and extensions.

It follows LibreSSL closely:

  • BER is accepted as LibreSSL accepts it (indefinite lengths, constructed strings up to five levels deep).
  • The tag/length cache works the same way.
  • Decoding into an existing certificate reuses it; a failure frees it and clears the pointer.
  • X509_free honours the reference count.
  • x509_cb sets ex_pathlen to -1 and caches the one-line subject with the X509_NAME_oneline from #11359.

The error queue gets the same codes, in the same order, as LibreSSL.

Api.hpp now has the full 176-byte X509 and the X509_CINF, X509_ALGOR, X509_VAL, X509_PUBKEY, X509_EXTENSION, ASN1_TYPE and ASN1_ENCODING layouts. They were checked with offsetof against the 2.5.4 headers. The existing references offset (28), which X509_STORE_CTX_get1_chain relies on, does not change.

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

  • The Field=/Type= error data is not kept, because the queue holds codes only.
  • Freeing a certificate with ex_data, auxiliary data, cached extensions or a decoded EVP_PKEY throws. No export creates them yet.

X509_get_pubkey is not part of this PR: it needs EVP_PKEY/RSA decoding.

Tested

Debian container, GCC 14.2, full Release build of head da60c57806: 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 decodes a hand-built certificate and checks:

    • every field, including the issuer's DER and canonical encodings and the cached name;
    • reuse of an existing certificate;
    • reference counting;
    • BER input;
    • seven malformed inputs, with the exact error codes LibreSSL 2.5.4 produces for them.
  • guest_libressl_x509_allocator fails each guest allocation of a decode in turn and checks that nothing leaks and that the decode either fails with an error or succeeds.

  • guest_libressl_oracle (ANYPS5_LIBRESSL_ORACLE) now also builds random certificates and decodes each one with both implementations. The certificates:

    • mix string types (including unknown universal tags, ENUMERATED and SEQUENCE values in names, BMP and Universal strings);
    • use constructed and indefinite encodings;
    • include ASN1_TYPE parameters of every class, optional fields, extensions and odd bit counts;
    • are mutated at random in about 40% of runs.

    For each case it compares every decoded field, the consumed length, the error queue and, for decodes into an existing certificate, what happened to the pointer. Results:

    • 60,000 cases in the test, and a 600,000-case run locally, with no difference.
    • The only differences the oracle reports are the 6 AES_set_*_key schedule cases already described in the debt file. They come from the reference building aes-x86_64.

Windows: see the run in the comments. Not tested 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: #11359, #11129
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5082924530 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266). Originally posted by [JaceTheBlu](https://github.com/JaceTheBlu) on 2026-10-30T10:28:57Z. --- ### What Implements `d2i_X509` and `X509_free` in libSceLibreSsl. This is stacked on #11359, and through it #11129. Merge those first; this PR's own diff is then only the decoder, its tests and its debt entry. `src/X509.cpp` ports the LibreSSL 2.5.4 template decoder (`tasn_dec.c`, `tasn_new.c`, `tasn_fre.c`), limited to the items an `X509` holds: - the certificate and `X509_CINF`, which keeps the encoding of the signed part; - algorithms with an `ASN1_TYPE` parameter; - names, through the `x_name.c` extern functions: the DER cache, entries with their RDN index, and the canonical encoding; - validity, the public key (left encoded) and extensions. It follows LibreSSL closely: - BER is accepted as LibreSSL accepts it (indefinite lengths, constructed strings up to five levels deep). - The tag/length cache works the same way. - Decoding into an existing certificate reuses it; a failure frees it and clears the pointer. - `X509_free` honours the reference count. - `x509_cb` sets `ex_pathlen` to -1 and caches the one-line subject with the `X509_NAME_oneline` from #11359. The error queue gets the same codes, in the same order, as LibreSSL. `Api.hpp` now has the full 176-byte `X509` and the `X509_CINF`, `X509_ALGOR`, `X509_VAL`, `X509_PUBKEY`, `X509_EXTENSION`, `ASN1_TYPE` and `ASN1_ENCODING` layouts. They were checked with `offsetof` against the 2.5.4 headers. The existing `references` offset (28), which `X509_STORE_CTX_get1_chain` relies on, does not change. There is a new entry in `docs/dev/debt/libSceLibreSsl.md`, and the pending count goes from 288 to 286: - The `Field=`/`Type=` error data is not kept, because the queue holds codes only. - Freeing a certificate with ex_data, auxiliary data, cached extensions or a decoded `EVP_PKEY` throws. No export creates them yet. `X509_get_pubkey` is not part of this PR: it needs `EVP_PKEY`/RSA decoding. ### Tested Debian container, GCC 14.2, full Release build of head `da60c57806`: `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`** decodes a hand-built certificate and checks: - every field, including the issuer's DER and canonical encodings and the cached name; - reuse of an existing certificate; - reference counting; - BER input; - seven malformed inputs, with the exact error codes LibreSSL 2.5.4 produces for them. - **`guest_libressl_x509_allocator`** fails each guest allocation of a decode in turn and checks that nothing leaks and that the decode either fails with an error or succeeds. - **`guest_libressl_oracle`** (`ANYPS5_LIBRESSL_ORACLE`) now also builds random certificates and decodes each one with both implementations. The certificates: - mix string types (including unknown universal tags, ENUMERATED and SEQUENCE values in names, BMP and Universal strings); - use constructed and indefinite encodings; - include `ASN1_TYPE` parameters of every class, optional fields, extensions and odd bit counts; - are mutated at random in about 40% of runs. For each case it compares every decoded field, the consumed length, the error queue and, for decodes into an existing certificate, what happened to the pointer. Results: - 60,000 cases in the test, and a 600,000-case run locally, with no difference. - The only differences the oracle reports are the 6 `AES_set_*_key` schedule cases already described in the debt file. They come from the reference building aes-x86_64. Windows: see the run in the comments. Not tested 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: #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 10:40:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-30T10:40:02Z.

Review: CHANGES_REQUESTED


Reviewed — changes requested

The required pull request template sections are missing, so the repository’s Conventions check fails on this head.

What I ran

Reviewed head: da60c5780644cd413f491df03d3f96dd15ec6c83. The PR targets main from base e198fd3cdc2290c579522d032e24a26e549cc6c4; a local merge preview against current main 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 merged cleanly. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5, and Debian GCC/G++ 12.2.0. I inspected the decoder, certificate/name ownership paths, API declarations, tests, CMake registration, contribution rules, and the hosted check snapshot; I did not compile or execute the C++ tests.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13266
git diff --check 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4...da60c5780644cd413f491df03d3f96dd15ec6c83
git merge-tree --write-tree 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 refs/review/pr-13266
python3 tools/pr_abi_audit.py --base 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 --head da60c5780644cd413f491df03d3f96dd15ec6c83
python3 tools/pr_test_quality.py --root /tmp/AnyPS5-pr13266-review core/libs/prx/libSceLibreSsl/tests/X509.cpp core/libs/tests/GuestLibreSslX509Name.cpp

Results

Check Result
PR template / conventions Failed: required ### What, ### Tested, and ### Checklist headings are absent.
Whitespace / patch Passed: git diff --check emitted no findings.
Current-main merge preview Passed: clean merge tree b3104fa1712c12e9a7a0b5b75564f7c82d08a45a.
Export declaration/NID audit Passed as a lexical audit; it does not establish compiled ABI correctness.
Test-quality heuristic Two possible registration warnings; manual inspection confirmed both C++ tests are registered in core/libs/prx/libSceLibreSsl/CMakeLists.txt.
Hosted CI Conventions failed; Windows was in progress; Linux and specialized jobs were skipped in the recorded snapshot. Eligibility, intake, labels, and report checks passed.
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
ABI audit: passed
core/libs/prx/libSceLibreSsl/tests/X509.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage.
core/libs/tests/GuestLibreSslX509Name.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage.
Heuristic findings require manual interpretation.
b3104fa1712c12e9a7a0b5b75564f7c82d08a45a

Findings

Blocking

  • Required PR template sections are missing. The repository’s contribution rules require using the PR template, and the exact-head Conventions job reports these three missing headings. Put the existing summary, test details, and dependency/debt checklist under ### What, ### Tested, and ### Checklist, retaining the applicable checklist items. Contribution rules at this PR head

Non-blocking

  • I did not identify a source-level blocker during this pass. The new C++ tests appear registered, but their runtime assertions have not been independently executed.

Not verified

  • No build or C++ test binary was run. Linux and specialized hosted jobs were skipped; the Windows job was still in progress in the captured CI snapshot.
  • Exact console behavior and compatibility of certificate decoding/freeing remain unverified here.

To get this to a good state

Restore the three required template headings and keep the existing dependency and tested-work details in the corresponding sections. I will rerun the same checks on the updated head; build-dependent behavior will remain unverified unless an applicable hosted run supplies that evidence.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5711097193 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5711097193). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-30T10:40:02Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested The required pull request template sections are missing, so the repository’s Conventions check fails on this head. ## What I ran Reviewed head: `da60c5780644cd413f491df03d3f96dd15ec6c83`. The PR targets `main` from base `e198fd3cdc2290c579522d032e24a26e549cc6c4`; a local merge preview against current `main` `3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4` merged cleanly. Environment: Linux x86_64, Python 3.11.2, Git 2.39.5, and Debian GCC/G++ 12.2.0. I inspected the decoder, certificate/name ownership paths, API declarations, tests, CMake registration, contribution rules, and the hosted check snapshot; I did not compile or execute the C++ tests. ```sh python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13266 git diff --check 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4...da60c5780644cd413f491df03d3f96dd15ec6c83 git merge-tree --write-tree 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 refs/review/pr-13266 python3 tools/pr_abi_audit.py --base 3d19f3fed31be38d7196ea1bd74e29ab6cc3c9a4 --head da60c5780644cd413f491df03d3f96dd15ec6c83 python3 tools/pr_test_quality.py --root /tmp/AnyPS5-pr13266-review core/libs/prx/libSceLibreSsl/tests/X509.cpp core/libs/tests/GuestLibreSslX509Name.cpp ``` ## Results | Check | Result | |---|---| | PR template / conventions | Failed: required `### What`, `### Tested`, and `### Checklist` headings are absent. | | Whitespace / patch | Passed: `git diff --check` emitted no findings. | | Current-main merge preview | Passed: clean merge tree `b3104fa1712c12e9a7a0b5b75564f7c82d08a45a`. | | Export declaration/NID audit | Passed as a lexical audit; it does not establish compiled ABI correctness. | | Test-quality heuristic | Two possible registration warnings; manual inspection confirmed both C++ tests are registered in `core/libs/prx/libSceLibreSsl/CMakeLists.txt`. | | Hosted CI | Conventions failed; Windows was in progress; Linux and specialized jobs were skipped in the recorded snapshot. Eligibility, intake, labels, and report checks passed. | <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 ``` ```text ABI audit: passed ``` ```text core/libs/prx/libSceLibreSsl/tests/X509.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage. core/libs/tests/GuestLibreSslX509Name.cpp:1: possible-unregistered-cpp-test: Changed C++ test source path was not found literally in CMake files; inspect registration, generated source lists, and workflow coverage. Heuristic findings require manual interpretation. ``` ```text b3104fa1712c12e9a7a0b5b75564f7c82d08a45a ``` </details> ## Findings ### Blocking - **Required PR template sections are missing.** The repository’s contribution rules require using the PR template, and the exact-head Conventions job reports these three missing headings. Put the existing summary, test details, and dependency/debt checklist under `### What`, `### Tested`, and `### Checklist`, retaining the applicable checklist items. [Contribution rules at this PR head](https://github.com/boykopovar/AnyPS5/blob/da60c5780644cd413f491df03d3f96dd15ec6c83/CONTRIBUTING.md#branches-and-pull-requests) ### Non-blocking - I did not identify a source-level blocker during this pass. The new C++ tests appear registered, but their runtime assertions have not been independently executed. ## Not verified - No build or C++ test binary was run. Linux and specialized hosted jobs were skipped; the Windows job was still in progress in the captured CI snapshot. - Exact console behavior and compatibility of certificate decoding/freeing remain unverified here. ## To get this to a good state Restore the three required template headings and keep the existing dependency and tested-work details in the corresponding sections. I will rerun the same checks on the updated head; build-dependent behavior will remain unverified unless an applicable hosted run supplies that evidence.
MarcZX10 commented 2026-10-31 10:35:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T10:35:37Z.

Review: APPROVED


Re-checked — new head, looks good

At head d865e35d15db1eb3ba5399b47bc80456bb1f581e, the template issue from my earlier review is fixed, and I found no source blocker.

What I ran

Reviewed head d865e35d15db1eb3ba5399b47bc80456bb1f581e against base c3c45d73abd34dca81da6bad87cb6d36ea437a66; its merge preview was clean against current main at fd31320e83fe417fa9c7fef792613653d9eb4f02. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or C++ tests were run.

python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13266
python3 tools/pr_abi_audit.py --base c3c45d73abd34dca81da6bad87cb6d36ea437a66 --head d865e35d15db1eb3ba5399b47bc80456bb1f581e --json
gh pr checks 13266 --repo boykopovar/AnyPS5

Results

Check Result
Diff check and conventions/template Passed
ABI declaration/export audit Passed; 406 symbols checked, no findings
Merge preview Clean against current main
Hosted Windows, conventions, eligibility, intake, labels, report and library portability Passed
Hosted Linux, relinker, ASAN and specialized jobs Skipped by workflow
C++ tests and oracle Not run locally. The PR description reports 38/38 focused tests and a 600,000-case oracle run on the earlier code head; I did not reproduce those runs.
Convention-check stdout (verbatim)
All conventions checks passed.

Findings

Blocking

None found in the reviewed decoder and ownership paths.

Non-blocking

The stack scan reports that the latest head of dependency #11129 is not included, although #13266 is clean against current main and its declared dependency #11359 is included. The PR already says to land its dependencies first; refresh the stack after those dependencies land and review the resulting head.

Sources

Not verified

I did not build the current head or run CTest/oracle locally. Console behavior is unmeasured, and the hosted Linux and specialized jobs were skipped.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5722375041 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5722375041). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-31T10:35:37Z. **Review:** APPROVED --- # Re-checked — new head, looks good At head `d865e35d15db1eb3ba5399b47bc80456bb1f581e`, the template issue from my earlier review is fixed, and I found no source blocker. ## What I ran Reviewed head `d865e35d15db1eb3ba5399b47bc80456bb1f581e` against base `c3c45d73abd34dca81da6bad87cb6d36ea437a66`; its merge preview was clean against current `main` at `fd31320e83fe417fa9c7fef792613653d9eb4f02`. Environment: Linux x86_64, Python 3.11.2, GCC 12.2.0. No local build or C++ tests were run. ```text python3 tools/pr_precheck.py --repo boykopovar/AnyPS5 --pr 13266 python3 tools/pr_abi_audit.py --base c3c45d73abd34dca81da6bad87cb6d36ea437a66 --head d865e35d15db1eb3ba5399b47bc80456bb1f581e --json gh pr checks 13266 --repo boykopovar/AnyPS5 ``` ## Results | Check | Result | |---|---| | Diff check and conventions/template | Passed | | ABI declaration/export audit | Passed; 406 symbols checked, no findings | | Merge preview | Clean against current `main` | | Hosted Windows, conventions, eligibility, intake, labels, report and library portability | Passed | | Hosted Linux, relinker, ASAN and specialized jobs | Skipped by workflow | | C++ tests and oracle | Not run locally. The PR description reports 38/38 focused tests and a 600,000-case oracle run on the earlier code head; I did not reproduce those runs. | <details><summary>Convention-check stdout (verbatim)</summary> ```text All conventions checks passed. ``` </details> ## Findings ### Blocking None found in the reviewed decoder and ownership paths. ### Non-blocking The stack scan reports that the latest head of dependency #11129 is not included, although #13266 is clean against current `main` and its declared dependency #11359 is included. The PR already says to land its dependencies first; refresh the stack after those dependencies land and review the resulting head. ## Sources - [Decoder and ownership implementation at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d865e35d15db1eb3ba5399b47bc80456bb1f581e/core/libs/prx/libSceLibreSsl/src/X509.cpp) - [Tests at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d865e35d15db1eb3ba5399b47bc80456bb1f581e/core/libs/prx/libSceLibreSsl/tests/X509.cpp) - [PR template at the reviewed head](https://github.com/boykopovar/AnyPS5/blob/d865e35d15db1eb3ba5399b47bc80456bb1f581e/.github/pull_request_template.md) ## Not verified I did not build the current head or run CTest/oracle locally. Console behavior is unmeasured, and the hosted Linux and specialized jobs were skipped.
XairRrR commented 2026-11-03 23:14:30 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T23:14:30Z.

Review: APPROVED


Reviewed — approved

The d2i_X509/X509_free port merges and builds cleanly, and all the LibreSSL tests pass. The new tests catch a stubbed decoder and targeted mutations, and the parts of the port I compared with LibreSSL 2.5.4 match it. I found nothing blocking.

What I ran

Head f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0 merged with --no-ff into main 1c8c0efc8c41314402e6966da5bef6ea3d639d10 in a clean worktree. Environment: Debian 13 VM with 32 vCPU (Xeon Gold 6136), GCC 14.2.0, Release, Ninja, BUILD_TESTING=ON.

git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0
python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10
ctest --test-dir build -j8 --test-load 32 --output-on-failure -R libressl
# negative control and mutations (see below), each followed by:
ninja -C build -j32 -l32 guest_libressl_x509_tests
ctest --test-dir build --output-on-failure -R '^guest_libressl_x509(_allocator)?$'
git status --porcelain

Results

Check Result
git diff --check clean
check_conventions.py All conventions checks passed.
Build (script) configure, build and libs succeeded
Selected tests (script) 2506 run, no new failures, no timeouts. The 4 known failures (guest_interfaces, guest_socket_options_multicast, unwrap_self_…, vector_constant_factor_tininess) also fail on main. The guest_net_ctl skip also happens on main.
ctest -R libressl 56/56 passed. Each new test (guest_libressl_x509, _x509_allocator, _x509_name, _x509_name_oneline, _x509_name_oneline_allocator) takes about 0.01 s.
Pending-export count in the debt file 231 → 224, which matches the NotImplemented_nid_no_patch(__func__) stubs left in Export.cpp
Vulkan validation not applicable (no AGC, shader or VideoOut files changed)

Negative control

Restoring main's production files is not a usable control: the tests use the new Api.hpp layouts and signatures, as JJenkx already observed. I used these instead:

  1. Stubs. I replaced src/X509.cpp with d2i_X509/X509_free that call NotImplemented_nid_no_patch, which is main's behaviour. Both guest_libressl_x509 and guest_libressl_x509_allocator abort with d2i_X509_nid_postfix not implemented.
  2. Bit-string mutation. I removed the unused-bit masking in BitStringFromContent (src/X509.cpp:585). guest_libressl_x509 fails with the signature keeps its unused bit count and clears the unused bits.
  3. Name-decode leak. I removed ItemFree(&internal, NameInternalItem) from the NameDecode failure path (src/X509.cpp:1714). guest_libressl_x509_allocator fails with nothing leaks.
  4. Push-failure leak. I removed ItemFree(&element, …) after a failed StackPush (src/X509.cpp:1309). guest_libressl_x509_allocator still passes; see the second non-blocking finding.

Afterwards I restored the merged src/X509.cpp and rebuilt. Both tests pass and git status --porcelain is empty.

Findings

Blocking

None.

Non-blocking

  • The new tests get a 60 s timeout. At CMakeLists.txt:394, guest_libressl_x509 and guest_libressl_x509_allocator get TIMEOUT 60. CONTRIBUTING says each test finishes in 30 s and that a test is shrunk rather than given a longer timeout. Both run in about 0.01 s here, so 30 (or the default) is enough. Suggested fix: use TIMEOUT 30, like the other tests in this file.
  • The allocator test never reaches the stack-growth failure path. StackPush only reallocates when a stack reaches 4 entries. The certificate in the allocator test has at most 3 entries in any stack (issuer sets, extensions). The cleanup at X509.cpp:1307-1311 is therefore never exercised: mutation 4 above leaks and the test still passes. The code is correct as written. Suggested fix: add a case with four or more extensions or name entries to the allocator run.
  • The description's pending count is stale. The description says the pending count "goes from 288 to 286". The debt file and Export.cpp actually go from 231 to 224: five X509_NAME exports come from the stacked #11129/#11359, plus these two.

On the existing discussion

  • 3rdparty question. oneandonlydean's question about building the port from 3rdparty/ is still waiting for a maintainer's answer, and I don't settle it here. One new data point: main already has the 3rdparty/libressl-openbsd submodule (pinned at 078b3d1df8ca, which contains the 2.5.4 commit 2e2c612066aa). ErrorQueue.cmake reads it at build time. I used it to compare the port with the 2.5.4 sources. If maintainers want the 3rdparty/ route, the source is already there.
  • Faithfulness checks. These are against that submodule at 2e2c612066aa:
    • CertificateCallback matches x509_cb. In 2.5.4 there is no ASN1_OP_D2I_PRE case, so a reused certificate keeps valid, ex_flags and ex_pathlen, as the port does. FREE_POST releases the fields the port refuses to free (it throws instead).
    • The canonical encoding passes a negative ENUMERATED name value through as its raw bytes, under tag 0x10a. 2.5.4's asn1_ex_i2c does the same, because it handles only V_ASN1_INTEGER/V_ASN1_ENUMERATED.

Not verified

  • guest_libressl_oracle (ANYPS5_LIBRESSL_ORACLE) is off in this build. It fetches LibreSSL 2.5.4 at configure time and the sandbox has no network, so I did not reproduce the 60,000-case and 600,000-case runs.
  • The stacked dependencies (#11129, #11359) are part of this diff. I checked X509_NAME_oneline only where d2i_X509 uses it, for the cached name.
  • Nothing was run on a PS5 or with a title. I did not run Windows; JJenkx's comment covers it on the earlier head da60c57806.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:5760833574 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5760833574). Originally posted by [XairRrR](https://github.com/XairRrR) on 2026-11-03T23:14:30Z. **Review:** APPROVED --- # Reviewed — approved The `d2i_X509`/`X509_free` port merges and builds cleanly, and all the LibreSSL tests pass. The new tests catch a stubbed decoder and targeted mutations, and the parts of the port I compared with LibreSSL 2.5.4 match it. I found nothing blocking. ## What I ran Head `f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0` merged with `--no-ff` into `main` `1c8c0efc8c41314402e6966da5bef6ea3d639d10` in a clean worktree. Environment: Debian 13 VM with 32 vCPU (Xeon Gold 6136), GCC 14.2.0, Release, Ninja, `BUILD_TESTING=ON`. ``` git diff --check 1c8c0efc8c41314402e6966da5bef6ea3d639d10...f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0 python3 tools/check_conventions.py --base 1c8c0efc8c41314402e6966da5bef6ea3d639d10 ctest --test-dir build -j8 --test-load 32 --output-on-failure -R libressl # negative control and mutations (see below), each followed by: ninja -C build -j32 -l32 guest_libressl_x509_tests ctest --test-dir build --output-on-failure -R '^guest_libressl_x509(_allocator)?$' git status --porcelain ``` ## Results | Check | Result | |---|---| | `git diff --check` | clean | | `check_conventions.py` | `All conventions checks passed.` | | Build (script) | configure, build and `libs` succeeded | | Selected tests (script) | 2506 run, no new failures, no timeouts. The 4 known failures (`guest_interfaces`, `guest_socket_options_multicast`, `unwrap_self_…`, `vector_constant_factor_tininess`) also fail on `main`. The `guest_net_ctl` skip also happens on `main`. | | `ctest -R libressl` | 56/56 passed. Each new test (`guest_libressl_x509`, `_x509_allocator`, `_x509_name`, `_x509_name_oneline`, `_x509_name_oneline_allocator`) takes about 0.01 s. | | Pending-export count in the debt file | 231 → 224, which matches the `NotImplemented_nid_no_patch(__func__)` stubs left in `Export.cpp` | | Vulkan validation | not applicable (no AGC, shader or VideoOut files changed) | ## Negative control Restoring `main`'s production files is not a usable control: the tests use the new `Api.hpp` layouts and signatures, as JJenkx already observed. I used these instead: 1. **Stubs.** I replaced `src/X509.cpp` with `d2i_X509`/`X509_free` that call `NotImplemented_nid_no_patch`, which is `main`'s behaviour. Both `guest_libressl_x509` and `guest_libressl_x509_allocator` abort with `d2i_X509_nid_postfix not implemented`. 2. **Bit-string mutation.** I removed the unused-bit masking in `BitStringFromContent` (`src/X509.cpp:585`). `guest_libressl_x509` fails with `the signature keeps its unused bit count and clears the unused bits`. 3. **Name-decode leak.** I removed `ItemFree(&internal, NameInternalItem)` from the `NameDecode` failure path (`src/X509.cpp:1714`). `guest_libressl_x509_allocator` fails with `nothing leaks`. 4. **Push-failure leak.** I removed `ItemFree(&element, …)` after a failed `StackPush` (`src/X509.cpp:1309`). `guest_libressl_x509_allocator` still **passes**; see the second non-blocking finding. Afterwards I restored the merged `src/X509.cpp` and rebuilt. Both tests pass and `git status --porcelain` is empty. ## Findings ### Blocking None. ### Non-blocking - **The new tests get a 60 s timeout.** At [`CMakeLists.txt:394`](https://github.com/boykopovar/AnyPS5/blob/f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0/core/libs/prx/libSceLibreSsl/CMakeLists.txt#L394-L394), `guest_libressl_x509` and `guest_libressl_x509_allocator` get `TIMEOUT 60`. CONTRIBUTING says each test finishes in 30 s and that a test is shrunk rather than given a longer timeout. Both run in about 0.01 s here, so 30 (or the default) is enough. Suggested fix: use `TIMEOUT 30`, like the other tests in this file. - **The allocator test never reaches the stack-growth failure path.** [`StackPush`](https://github.com/boykopovar/AnyPS5/blob/f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0/core/libs/prx/libSceLibreSsl/src/X509.cpp#L357-L368) only reallocates when a stack reaches 4 entries. The certificate in the [allocator test](https://github.com/boykopovar/AnyPS5/blob/f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0/core/libs/prx/libSceLibreSsl/tests/X509.cpp#L272-L278) has at most 3 entries in any stack (issuer sets, extensions). The cleanup at [`X509.cpp:1307-1311`](https://github.com/boykopovar/AnyPS5/blob/f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0/core/libs/prx/libSceLibreSsl/src/X509.cpp#L1307-L1311) is therefore never exercised: mutation 4 above leaks and the test still passes. The code is correct as written. Suggested fix: add a case with four or more extensions or name entries to the allocator run. - **The description's pending count is stale.** The description says the pending count "goes from 288 to 286". The debt file and `Export.cpp` actually go from 231 to 224: five X509_NAME exports come from the stacked #11129/#11359, plus these two. ### On the existing discussion - **3rdparty question.** oneandonlydean's question about building the port from `3rdparty/` is still waiting for a maintainer's answer, and I don't settle it here. One new data point: `main` already has the `3rdparty/libressl-openbsd` submodule (pinned at `078b3d1df8ca`, which contains the 2.5.4 commit `2e2c612066aa`). [`ErrorQueue.cmake`](https://github.com/boykopovar/AnyPS5/blob/f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0/core/libs/prx/libSceLibreSsl/ErrorQueue.cmake#L6-L10) reads it at build time. I used it to compare the port with the 2.5.4 sources. If maintainers want the `3rdparty/` route, the source is already there. - **Faithfulness checks.** These are against that submodule at `2e2c612066aa`: - `CertificateCallback` matches [`x509_cb`](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/x_x509.c#L172-L211). In 2.5.4 there is no `ASN1_OP_D2I_PRE` case, so a reused certificate keeps `valid`, `ex_flags` and `ex_pathlen`, as the port does. `FREE_POST` releases the fields the port refuses to free (it throws instead). - The canonical encoding passes a negative ENUMERATED name value through as its raw bytes, under tag 0x10a. 2.5.4's `asn1_ex_i2c` does the same, because it handles only `V_ASN1_INTEGER`/`V_ASN1_ENUMERATED`. ## Not verified - `guest_libressl_oracle` (`ANYPS5_LIBRESSL_ORACLE`) is off in this build. It fetches LibreSSL 2.5.4 at configure time and the sandbox has no network, so I did not reproduce the 60,000-case and 600,000-case runs. - The stacked dependencies (#11129, #11359) are part of this diff. I checked `X509_NAME_oneline` only where `d2i_X509` uses it, for the cached `name`. - Nothing was run on a PS5 or with a title. I did not run Windows; JJenkx's comment covers it on the earlier head `da60c57806`. <!-- anyps5-bots job=2829 head=f51c1c80e3074d9c0b14a3adc24ba4da5c01fef0 -->
MarcZX10 commented 2026-11-14 06:16:36 +00:00 (Migrated from github.com)

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

Review: CHANGES_REQUESTED


Reviewed — changes requested

Changes are required before merge: reject negative input lengths before using them as buffer bounds.

What I ran

Reviewed head 06d66e4b08ae5468a2bada43bd2d6927a06ec42b. I inspected the prepared diff and all eight changed files; no commands or tests were run in this read-only review.

Results

Check Result Note
Diff and changed files passed All eight changed files read
Build and tests not run No execution available
Decoder bounds failed Negative lengths are not rejected

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/X509.cpp:1864-1869: d2i_X509 validates null pointers but not a negative length. The decoder passes it to GetObject, which only checks !max before dereferencing the input and later uses the negative value in pointer bounds arithmetic (core/libs/prx/libSceLibreSsl/src/X509.cpp:885-887, 916). A caller can therefore trigger an out-of-bounds read or invalid pointer arithmetic by supplying a negative length. Return failure for negative lengths before entering the decoder.

Non-blocking

None.

Not verified

Build, tests, Windows behavior, and console behavior were not run. The author reports Linux test and oracle runs in the description; those results were not independently verified. Read: 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/tests/Oracle.cpp, core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp, core/libs/prx/libSceLibreSsl/tests/X509.cpp, and docs/dev/debt/libSceLibreSsl.md. No changed files were excluded.

To get this to a good state

Reject negative input lengths before parsing, then rerun the decoder tests and the reported build checks on the updated head.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5902204546 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5902204546). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-14T06:16:36Z. **Review:** CHANGES_REQUESTED --- # Reviewed — changes requested Changes are required before merge: reject negative input lengths before using them as buffer bounds. ## What I ran Reviewed head `06d66e4b08ae5468a2bada43bd2d6927a06ec42b`. I inspected the prepared diff and all eight changed files; no commands or tests were run in this read-only review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed files | passed | All eight changed files read | | Build and tests | not run | No execution available | | Decoder bounds | failed | Negative lengths are not rejected | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/X509.cpp:1864-1869`: `d2i_X509` validates null pointers but not a negative `length`. The decoder passes it to `GetObject`, which only checks `!max` before dereferencing the input and later uses the negative value in pointer bounds arithmetic (`core/libs/prx/libSceLibreSsl/src/X509.cpp:885-887, 916`). A caller can therefore trigger an out-of-bounds read or invalid pointer arithmetic by supplying a negative length. Return failure for negative lengths before entering the decoder. ### Non-blocking None. ## Not verified Build, tests, Windows behavior, and console behavior were not run. The author reports Linux test and oracle runs in the description; those results were not independently verified. Read: `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/tests/Oracle.cpp`, `core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp`, `core/libs/prx/libSceLibreSsl/tests/X509.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. No changed files were excluded. ## To get this to a good state Reject negative input lengths before parsing, then rerun the decoder tests and the reported build checks on the updated head.
MarcZX10 commented 2026-11-16 11:17:15 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — comments

This review inspected all eight changed files at head 4c4fe904879c5615aa342815ecac2868f82c22b5; no blocking defect was verified, but the changed API is not connected to the library's export registry.

What I ran

Read the prepared description, commit list, diff, manifest, and full text for every file listed as reviewed. Inspected related library export configuration. No build or tests were run in this review; test results in the description are author-reported.

Results

Check Result Note
Changed files read passed All eight reviewed files
Build and tests not run Description reports author-run checks
Export registration not verified No matching export declaration found in Export.cpp

Findings

Blocking

None.

Non-blocking

  • The implementation and header declare d2i_X509_nid_postfix and X509_free_nid_postfix, but neither is present in Export.cpp. Please confirm these functions are exposed through the generated library export table and add the required registrations if they are not; otherwise callers resolving the PRX exports will not reach the implementations. Changed declaration lines: core/libs/prx/libSceLibreSsl/include/Api.hpp:995 and core/libs/prx/libSceLibreSsl/include/Api.hpp:1009.

Not verified

No tests were run. The full text of all eight files marked included in the manifest was read: 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/tests/Oracle.cpp, core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp, core/libs/prx/libSceLibreSsl/tests/X509.cpp, and docs/dev/debt/libSceLibreSsl.md. No files were excluded by the manifest. Export generation/registration outside these files was not confirmed.

To get this to a good state

Nothing is required. Optional: verify the generated export table includes both functions and add registration if needed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5919092386 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5919092386). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-16T11:17:15Z. **Review:** COMMENTED --- # Reviewed — comments This review inspected all eight changed files at head `4c4fe904879c5615aa342815ecac2868f82c22b5`; no blocking defect was verified, but the changed API is not connected to the library's export registry. ## What I ran Read the prepared description, commit list, diff, manifest, and full text for every file listed as reviewed. Inspected related library export configuration. No build or tests were run in this review; test results in the description are author-reported. ## Results | Check | Result | Note | |---|---|---| | Changed files read | passed | All eight reviewed files | | Build and tests | not run | Description reports author-run checks | | Export registration | not verified | No matching export declaration found in `Export.cpp` | ## Findings ### Blocking None. ### Non-blocking - The implementation and header declare `d2i_X509_nid_postfix` and `X509_free_nid_postfix`, but neither is present in `Export.cpp`. Please confirm these functions are exposed through the generated library export table and add the required registrations if they are not; otherwise callers resolving the PRX exports will not reach the implementations. Changed declaration lines: `core/libs/prx/libSceLibreSsl/include/Api.hpp:995` and `core/libs/prx/libSceLibreSsl/include/Api.hpp:1009`. ## Not verified No tests were run. The full text of all eight files marked included in the manifest was read: `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/tests/Oracle.cpp`, `core/libs/prx/libSceLibreSsl/tests/OracleReference.cpp`, `core/libs/prx/libSceLibreSsl/tests/X509.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. No files were excluded by the manifest. Export generation/registration outside these files was not confirmed. ## To get this to a good state Nothing is required. Optional: verify the generated export table includes both functions and add registration if needed.
MarcZX10 commented 2026-11-17 13:32:56 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-17T13:32:56Z.

Review: COMMENTED


Reviewed d2i_X509 and X509_free — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head reviewed: 89b23f5a5f, base main.
  • Read the full diff (diff.patch) and manifest.json, files.json, description.md and commits.md from the review folder.
  • Checked names in the head with repo_read.py search: X509_NAME_oneline_nid_postfix, and the callers of X509_free_nid_postfix.
  • No build and no tests were run in this review.

Results

Check Result Note
Diff read, 8 of 8 reviewed files passed Full text of files not read, see Not verified
X509_NAME_oneline used by the decoder passed Declared in Api.hpp, defined in X509NameOneline.cpp
Callers of the changed signatures passed Only the tests call them; ParentExports forwards by symbol
Test names against the description failed Names differ, see Findings
Build and ctest not run Author-reported only
Commands
repo_read.py search X509_NAME_oneline_nid_postfix
repo_read.py search X509_free_nid_postfix

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceLibreSsl/CMakeLists.txt:806 registers guest_libressl_x509_der and guest_libressl_x509_der_allocator (line 807). The description names guest_libressl_x509 and guest_libressl_x509_allocator. Either the description or the registration should change so that a reader can find the tests by the names given.

Not verified

  • The build, ctest -R 'libressl|crypto_memcmp' (38 of 38) and the 600,000-case oracle run are the author's report. I did not run them.
  • The Windows run and the PS5 behaviour are not checked. The debt entry already says the code is unverified on PS5.
  • The description says this PR is stacked on #11359 and #11129 and must be merged after them. The diff against main does not include X509NameOneline.cpp, which the decoder calls, so those PRs may already be in main. I did not check their merge state.
  • The pending count in docs/dev/debt/libSceLibreSsl.md (288 to 286) is not checked; the diff only adds one entry line.
  • Not read at head: the full text of X509.cpp and Api.hpp, and the definitions of LibreSslX509Name, LibreSslX509NameEntry, LibreSslExData, LibreSslStack and the Error.hpp and ObjectTable.hpp includes. I read these only through the diff.
  • Files: all 8 files in files.json under reviewed were read through their diff hunks. None were excluded.

To get this to a good state

Nothing is required. The naming point above is optional.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5939399365 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-5939399365). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-17T13:32:56Z. **Review:** COMMENTED --- # Reviewed d2i_X509 and X509_free — no blocking findings Nothing blocks this; the points below are optional. ## What I ran - Head reviewed: 89b23f5a5f818897300e9ad41ef2e29194df1a5c, base main. - Read the full diff (`diff.patch`) and `manifest.json`, `files.json`, `description.md` and `commits.md` from the review folder. - Checked names in the head with `repo_read.py search`: `X509_NAME_oneline_nid_postfix`, and the callers of `X509_free_nid_postfix`. - No build and no tests were run in this review. ## Results | Check | Result | Note | |---|---|---| | Diff read, 8 of 8 reviewed files | passed | Full text of files not read, see Not verified | | `X509_NAME_oneline` used by the decoder | passed | Declared in Api.hpp, defined in X509NameOneline.cpp | | Callers of the changed signatures | passed | Only the tests call them; ParentExports forwards by symbol | | Test names against the description | failed | Names differ, see Findings | | Build and ctest | not run | Author-reported only | <details> <summary>Commands</summary> ``` repo_read.py search X509_NAME_oneline_nid_postfix repo_read.py search X509_free_nid_postfix ``` </details> ## Findings ### Blocking None. ### Non-blocking - `core/libs/prx/libSceLibreSsl/CMakeLists.txt:806` registers `guest_libressl_x509_der` and `guest_libressl_x509_der_allocator` (line 807). The description names `guest_libressl_x509` and `guest_libressl_x509_allocator`. Either the description or the registration should change so that a reader can find the tests by the names given. ## Not verified - The build, `ctest -R 'libressl|crypto_memcmp'` (38 of 38) and the 600,000-case oracle run are the author's report. I did not run them. - The Windows run and the PS5 behaviour are not checked. The debt entry already says the code is unverified on PS5. - The description says this PR is stacked on #11359 and #11129 and must be merged after them. The diff against main does not include `X509NameOneline.cpp`, which the decoder calls, so those PRs may already be in main. I did not check their merge state. - The pending count in `docs/dev/debt/libSceLibreSsl.md` (288 to 286) is not checked; the diff only adds one entry line. - Not read at head: the full text of `X509.cpp` and `Api.hpp`, and the definitions of `LibreSslX509Name`, `LibreSslX509NameEntry`, `LibreSslExData`, `LibreSslStack` and the `Error.hpp` and `ObjectTable.hpp` includes. I read these only through the diff. - Files: all 8 files in `files.json` under `reviewed` were read through their diff hunks. None were excluded. ## To get this to a good state Nothing is required. The naming point above is optional.
MarcZX10 commented 2026-11-21 13:54:59 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-21T13:54:59Z.

Review: DISMISSED


Reviewed — changes requested

Changes are required before merge: reject lengths that overflow the constructed-string accumulator before converting or allocating.

What I ran

Reviewed head 4d13d0448d3a2a1ad46ee6668f04e00a50647b8f against the prepared diff. No build or tests were run. The author reports a Debian/GCC 14.2 Release build and 38 passing tests, plus a 600,000-case oracle run; these were not run during this review.

Results

Check Result Note
Diff and changed code passed All eight changed files read
Build and tests not run Author-reported results only
Console behavior not run Author reports no console testing

Findings

Blocking

  • core/libs/prx/libSceLibreSsl/src/X509.cpp:1021-1026 converts buffer->length to int and adds the untrusted decoded length using signed arithmetic, then casts the result to size_t for Grow. A constructed ASN.1 string can contain enough segments to exceed INT_MAX; the conversion or addition can wrap, causing an undersized buffer allocation followed by memcpy of the full segment length. Keep the accumulator in a checked unsigned/wide type and reject totals that cannot be represented or allocated before growing or copying.

Non-blocking

None.

Not verified

  • Build, registered tests, oracle run, Windows behavior, and physical-console behavior were not independently verified.
  • Read: core/libs/prx/libSceLibreSsl/CMakeLists.txt, Export.cpp, include/Api.hpp, src/X509.cpp, tests/Oracle.cpp, tests/OracleReference.cpp, tests/X509.cpp, and docs/dev/debt/libSceLibreSsl.md. All changed files listed in the manifest were included and read; no changed files were excluded.

To get this to a good state

  • Guard the constructed-string length accumulation against overflow and allocation-size limits, then rerun the decoder tests and oracle against the updated head.
<!-- greyfinch-sync:boykopovar/AnyPS5:review:6005695389 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-6005695389). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-21T13:54:59Z. **Review:** DISMISSED --- # Reviewed — changes requested Changes are required before merge: reject lengths that overflow the constructed-string accumulator before converting or allocating. ## What I ran Reviewed head `4d13d0448d3a2a1ad46ee6668f04e00a50647b8f` against the prepared diff. No build or tests were run. The author reports a Debian/GCC 14.2 Release build and 38 passing tests, plus a 600,000-case oracle run; these were not run during this review. ## Results | Check | Result | Note | |---|---|---| | Diff and changed code | passed | All eight changed files read | | Build and tests | not run | Author-reported results only | | Console behavior | not run | Author reports no console testing | ## Findings ### Blocking - `core/libs/prx/libSceLibreSsl/src/X509.cpp:1021-1026` converts `buffer->length` to `int` and adds the untrusted decoded `length` using signed arithmetic, then casts the result to `size_t` for `Grow`. A constructed ASN.1 string can contain enough segments to exceed `INT_MAX`; the conversion or addition can wrap, causing an undersized buffer allocation followed by `memcpy` of the full segment length. Keep the accumulator in a checked unsigned/wide type and reject totals that cannot be represented or allocated before growing or copying. ### Non-blocking None. ## Not verified - Build, registered tests, oracle run, Windows behavior, and physical-console behavior were not independently verified. - Read: `core/libs/prx/libSceLibreSsl/CMakeLists.txt`, `Export.cpp`, `include/Api.hpp`, `src/X509.cpp`, `tests/Oracle.cpp`, `tests/OracleReference.cpp`, `tests/X509.cpp`, and `docs/dev/debt/libSceLibreSsl.md`. All changed files listed in the manifest were included and read; no changed files were excluded. ## To get this to a good state - Guard the constructed-string length accumulation against overflow and allocation-size limits, then rerun the decoder tests and oracle against the updated head.
MarcZX10 commented 2026-11-22 13:28:05 +00:00 (Migrated from github.com)

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

Review: COMMENTED


Reviewed — no blocking findings

The inspected implementation of d2i_X509 and X509_free appears consistent with the stated goal; a complete review is not justified because the review interface truncated long reads before all changed lines could be inspected.

What I ran

Reviewed head f024b6b00cf0e41d72a0cdf942ccd6cc6dcce160 using repo_read.py via the review reader. No build or tests were run.

Results

Check Result Note
Changed code inspection not run Long changed-line ranges were truncated
Build and tests not run No commands were run
Head passed Matches the prepared review artifacts

Findings

Blocking

None in the code inspected.

Non-blocking

None.

Not verified

The review artifacts list eight changed files, all marked included. I read the description, commit list, README, parts of the diff and manifest, and selected ranges of X509.cpp, Api.hpp, CMakeLists.txt, Export.cpp, tests/X509.cpp, tests/Oracle.cpp, tests/OracleReference.cpp, and the debt file. The reader capped long reads at 400 lines, so I did not inspect every added line in the changed files or all relevant callers. No build, tests, console behavior, or performance checks were verified.

To get this to a good state

Nothing is required. Optional: complete inspection of the remaining changed lines and run the reported checks on this exact head before approval.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6012488694 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-6012488694). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-22T13:28:05Z. **Review:** COMMENTED --- # Reviewed — no blocking findings The inspected implementation of `d2i_X509` and `X509_free` appears consistent with the stated goal; a complete review is not justified because the review interface truncated long reads before all changed lines could be inspected. ## What I ran Reviewed head `f024b6b00cf0e41d72a0cdf942ccd6cc6dcce160` using `repo_read.py` via the review reader. No build or tests were run. ## Results | Check | Result | Note | |---|---|---| | Changed code inspection | not run | Long changed-line ranges were truncated | | Build and tests | not run | No commands were run | | Head | passed | Matches the prepared review artifacts | ## Findings ### Blocking None in the code inspected. ### Non-blocking None. ## Not verified The review artifacts list eight changed files, all marked included. I read the description, commit list, README, parts of the diff and manifest, and selected ranges of `X509.cpp`, `Api.hpp`, `CMakeLists.txt`, `Export.cpp`, `tests/X509.cpp`, `tests/Oracle.cpp`, `tests/OracleReference.cpp`, and the debt file. The reader capped long reads at 400 lines, so I did not inspect every added line in the changed files or all relevant callers. No build, tests, console behavior, or performance checks were verified. ## To get this to a good state Nothing is required. Optional: complete inspection of the remaining changed lines and run the reported checks on this exact head before approval.
ligmaSec commented 2026-12-03 13:25:02 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T13:25:02Z.

Review: COMMENTED


Built the focused checks against the existing Linux runtime. The X509 fixture passed. The two reference-oracle executables did not build in this standalone setup.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6170651825 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/13266#pullrequestreview-6170651825). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T13:25:02Z. **Review:** COMMENTED --- Built the focused checks against the existing Linux runtime. The `X509` fixture passed. The two reference-oracle executables did not build in this standalone setup. AI-assisted: yes.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/13266:upstream-pr/13266'
git switch 'upstream-pr/13266'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/13266'
git switch 'upstream-pr/13266'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/13266'
git switch 'upstream-pr/13266'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/13266'
git switch 'main'
git merge --squash 'upstream-pr/13266'
git switch 'main'
git merge --ff-only 'upstream-pr/13266'
git switch 'main'
git merge 'upstream-pr/13266'
git push origin 'main'
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!13266
No description provided.