feat(libSceLibreSsl3): accept NULL in PKCS7_free, PKCS8_PRIV_KEY_INFO_free and OCSP_CERTID_free #16111

Closed
MarrasFederico wants to merge 3 commits from upstream-pr/16111 into main
MarrasFederico commented 2026-11-05 17:31:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarrasFederico on 2026-11-05T17:31:28Z.


What

PKCS7_free, PKCS8_PRIV_KEY_INFO_free and OCSP_CERTID_free in libSceLibreSsl3 threw for every call, NULL included. Cleanup code usually calls these on pointers that may still be NULL. In LibreSSL 4.0.0 each one is ASN1_item_free, which returns at once for NULL.

All three now return without action for NULL. A non-null object still throws: this module has no constructor for these types (d2i_PKCS7, d2i_PKCS8_PRIV_KEY_INFO_bio and OCSP_cert_to_id are unimplemented), so no such object can be released correctly yet.

  • They move from Export.cpp to src/Asn1Free.cpp with void (void*) signatures, as in LibreSSL.
  • The pending-exports count drops from 68 to 65.

Not measured on a console.

Tested

Ubuntu 26.04.1, kernel 7.0.0, GCC 15.2.0, Release, BUILD_TESTING=ON, on main 6e6dae4e8b. Windows and macOS were not compiled here. No title was run.

  • New guest_libressl3_asn1_free passes: each function returns for NULL without throwing. All 14 LibreSSL3 tests pass.
  • On main the test does not compile against the (void) declarations, and the placeholders throw.
  • check_conventions.py --base upstream/main passes.
  • pr_overlap.py: several open LibreSSL3 PRs (#15631, #15737, #15758, #15760, #15761, #15765, #15770, #15899) and my #15599 and #15601 touch the same CMake, header and pending-export lines; none implements these three functions (searched by name in open PRs).

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
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5175869151 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16111). Originally posted by [MarrasFederico](https://github.com/MarrasFederico) on 2026-11-05T17:31:28Z. --- ### What `PKCS7_free`, `PKCS8_PRIV_KEY_INFO_free` and `OCSP_CERTID_free` in libSceLibreSsl3 threw for every call, NULL included. Cleanup code usually calls these on pointers that may still be NULL. In LibreSSL 4.0.0 each one is `ASN1_item_free`, which [returns at once for NULL](https://github.com/libressl/openbsd/blob/ce488b78e0bd994780569df718596b9776ff681a/src/lib/libcrypto/asn1/tasn_fre.c). All three now return without action for NULL. A non-null object still throws: this module has no constructor for these types (`d2i_PKCS7`, `d2i_PKCS8_PRIV_KEY_INFO_bio` and `OCSP_cert_to_id` are unimplemented), so no such object can be released correctly yet. - They move from `Export.cpp` to `src/Asn1Free.cpp` with `void (void*)` signatures, as in LibreSSL. - The pending-exports count drops from 68 to 65. Not measured on a console. ### Tested <!-- OS, title or homebrew, what was checked. "Not tested" is a valid answer. A performance change: the summary lines of main and of this PR from the same machine and scene, with the traces attached, captured as the Performance report issue form describes. --> Ubuntu 26.04.1, kernel 7.0.0, GCC 15.2.0, Release, `BUILD_TESTING=ON`, on main `6e6dae4e8b`. Windows and macOS were not compiled here. No title was run. - New `guest_libressl3_asn1_free` passes: each function returns for NULL without throwing. All 14 LibreSSL3 tests pass. - On main the test does not compile against the `(void)` declarations, and the placeholders throw. - `check_conventions.py --base upstream/main` passes. - `pr_overlap.py`: several open LibreSSL3 PRs ([#15631](https://github.com/boykopovar/AnyPS5/pull/15631), [#15737](https://github.com/boykopovar/AnyPS5/pull/15737), [#15758](https://github.com/boykopovar/AnyPS5/pull/15758), [#15760](https://github.com/boykopovar/AnyPS5/pull/15760), [#15761](https://github.com/boykopovar/AnyPS5/pull/15761), [#15765](https://github.com/boykopovar/AnyPS5/pull/15765), [#15770](https://github.com/boykopovar/AnyPS5/pull/15770), [#15899](https://github.com/boykopovar/AnyPS5/pull/15899)) and my [#15599](https://github.com/boykopovar/AnyPS5/pull/15599) and [#15601](https://github.com/boykopovar/AnyPS5/pull/15601) touch the same CMake, header and pending-export lines; none implements these three functions (searched by name in open PRs). ### 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 <!-- #PR, or none --> - [x] Fixes: none <!-- issue it closes as Fixes #N, or none --> - [x] Unblocks: none <!-- title ID and Game bring-up discussion, e.g. PPSA01325 #3232, or none --> - [x] GPUs tested: n/a <!-- for AGC, shader recompiler or VideoOut changes: vendor, model, driver and OS of each GPU the GPU tests ran on; otherwise n/a --> - [x] AI-assisted: yes <!-- yes / no -->

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!16111
No description provided.