fix(libSceLibreSsl): reject null strings in the ASN.1 accessors as invalid arguments #11111

Merged
mantavisual merged 1 commit from upstream-pr/11111 into main 2026-10-26 09:09:21 +00:00
mantavisual commented 2026-10-25 18:11:20 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mantavisual on 2026-10-25T18:11:20Z.


What

ASN1_STRING_data, ASN1_STRING_length and ASN1_STRING_type are implemented, but each throws NotImplemented_nid_no_patch for a null string, so they are still counted as stubs. That behaviour is known rather than unimplemented: LibreSSL 2.5.4's asn1_lib.c, the version the docs/dev/debt/libSceLibreSsl.md ASN.1 entry follows, returns x->length, x->type and x->data without a check, so a null string faults.

This changes the three null checks to APS5_INVALID_ARG_EX, as the DES functions in this library already do where LibreSSL faults (Null pointers throw where LibreSSL faults in the same debt file). They still throw for null, and the debt entry's "Null accessor inputs ... throw where the source has undefined behaviour" stays accurate, so the debt file is unchanged. Non-null behaviour is unchanged.

ASN1_INTEGER_get is left as it is. Its remaining throw covers magnitudes beyond the signed 64-bit range, where 2.5.4's signed shift and negation are undefined behaviour, not a null input.

Tested

Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, BUILD_TESTING=ON, on main ac65cf490e.

  • guest_libressl_asn1: the three null-input checks now require std::invalid_argument, not any exception. On main they get the std::runtime_error from NotImplemented_nid_no_patch, so the new check fails there and passes here. The existing non-null accessor checks are unchanged and pass.
  • ctest -R "guest_libressl|patched_libraries": 11 of 11 pass, after rebuilding every LibreSSL and LibreSSL3 test target and the NID-patched libSceLibreSsl.prx.
  • tools/progress.py --module libSceLibreSsl: 48 → 51 implemented, 351 → 348 stubs. tools/check_test_registration.py build: 1353 test executables, none built and not run.
  • python3 tools/check_conventions.py --base origin/main passes. Overlap: no open PR changes these three functions (checked 2026-10-25 against the heads of the 54 open PRs that mention LibreSSL or OpenSSL). #11050 edits ASN1_STRING_to_UTF8 in the same file, in different hunks.

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: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5007343598 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11111). Originally posted by [mantavisual](https://github.com/mantavisual) on 2026-10-25T18:11:20Z. --- ### What `ASN1_STRING_data`, `ASN1_STRING_length` and `ASN1_STRING_type` are implemented, but each throws `NotImplemented_nid_no_patch` for a null string, so they are still counted as stubs. That behaviour is known rather than unimplemented: [LibreSSL 2.5.4's asn1_lib.c](https://github.com/libressl/openbsd/blob/2e2c612066aa993717528a0249c15c51128d61cb/src/lib/libcrypto/asn1/asn1_lib.c#L468-L490), the version the `docs/dev/debt/libSceLibreSsl.md` ASN.1 entry follows, returns `x->length`, `x->type` and `x->data` without a check, so a null string faults. This changes the three null checks to `APS5_INVALID_ARG_EX`, as the DES functions in this library already do where LibreSSL faults (`Null pointers throw where LibreSSL faults` in the same debt file). They still throw for null, and the debt entry's "Null accessor inputs ... throw where the source has undefined behaviour" stays accurate, so the debt file is unchanged. Non-null behaviour is unchanged. `ASN1_INTEGER_get` is left as it is. Its remaining throw covers magnitudes beyond the signed 64-bit range, where 2.5.4's signed shift and negation are undefined behaviour, not a null input. ### Tested Windows 11 Pro 23H2, WinLibs GCC 15.2.0 r7, Release, `BUILD_TESTING=ON`, on `main` `ac65cf490e`. - `guest_libressl_asn1`: the three null-input checks now require `std::invalid_argument`, not any exception. On `main` they get the `std::runtime_error` from `NotImplemented_nid_no_patch`, so the new check fails there and passes here. The existing non-null accessor checks are unchanged and pass. - `ctest -R "guest_libressl|patched_libraries"`: 11 of 11 pass, after rebuilding every LibreSSL and LibreSSL3 test target and the NID-patched `libSceLibreSsl.prx`. - `tools/progress.py --module libSceLibreSsl`: 48 → 51 implemented, 351 → 348 stubs. `tools/check_test_registration.py build`: 1353 test executables, none built and not run. - `python3 tools/check_conventions.py --base origin/main` passes. Overlap: no open PR changes these three functions (checked 2026-10-25 against the heads of the 54 open PRs that mention LibreSSL or OpenSSL). #11050 edits `ASN1_STRING_to_UTF8` in the same file, in different hunks. ### 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: none - [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-25 18:13:13 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-25T18:13:13Z.

Review: APPROVED


Reviewed exact head . The three accessor changes match the pinned LibreSSL 2.5.4 source, whose accessors dereference the supplied without null guards. The focused tests now check the intended exception type while preserving the non-null accessor behavior. Eligibility, conventions, intake, labels and report checks pass; product/relinker jobs were skipped by path policy, so I rely on the reported local Windows target runs for those tests.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5644583294 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/11111#pullrequestreview-5644583294). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-10-25T18:13:13Z. **Review:** APPROVED --- Reviewed exact head . The three accessor changes match the pinned LibreSSL 2.5.4 source, whose accessors dereference the supplied without null guards. The focused tests now check the intended exception type while preserving the non-null accessor behavior. Eligibility, conventions, intake, labels and report checks pass; product/relinker jobs were skipped by path policy, so I rely on the reported local Windows target runs for those tests.
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!11111
No description provided.