feat(libSceLibreSsl): implement BIO_printf #16529

Open
MarcZX10 wants to merge 3 commits from upstream-pr/16529 into main
MarcZX10 commented 2026-11-07 00:48:33 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-07T00:48:33Z.


What

  • Implements BIO_printf in libSceLibreSsl, formatting through the libc vsnprintf export and writing through the BIO's write method.
  • Returns the byte count reported by the BIO write method, including short writes. A null format throws std::invalid_argument.
  • BIO_vfree is not included; its implementation is handled separately by open PR #16654.

Tested

  • Added cases to guest_libressl_bio for ordinary formatting, output longer than the stack buffer, an empty format, a read-only BIO, and a short-writing BIO.
  • On the rebased head, git diff --check, repository conventions, and the changed-export ABI audit were run. No C++ build or guest test executable was run locally after the rebase; the new head will trigger hosted checks.
  • The workflow's previous Windows run was green on the old head; it does not verify this rebased head.

Checklist

  • Based on current main; no other open PR implements the same function
  • 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:5196896870 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16529). Originally posted by [MarcZX10](https://github.com/MarcZX10) on 2026-11-07T00:48:33Z. --- ### What - Implements `BIO_printf` in `libSceLibreSsl`, formatting through the libc `vsnprintf` export and writing through the BIO's write method. - Returns the byte count reported by the BIO write method, including short writes. A null format throws `std::invalid_argument`. - `BIO_vfree` is not included; its implementation is handled separately by open PR #16654. ### Tested - Added cases to `guest_libressl_bio` for ordinary formatting, output longer than the stack buffer, an empty format, a read-only BIO, and a short-writing BIO. - On the rebased head, `git diff --check`, repository conventions, and the changed-export ABI audit were run. No C++ build or guest test executable was run locally after the rebase; the new head will trigger hosted checks. - The workflow's previous Windows run was green on the old head; it does not verify this rebased head. ### Checklist - [x] Based on current `main`; no other open PR implements the same function - [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
adriadam10 commented 2026-11-10 18:43:18 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-10T18:43:18Z.

Review: CHANGES_REQUESTED


Checked the diff against the PR thread and #16654. Needs a few changes:

  • The PR body no longer matches the diff: it describes 19 exports (BIO_meth_*, BN_dup, BN_div, BN_print, ...) and tests that are not in this head. The diff only implements BIO_printf and BIO_vfree. Please rewrite What/Tested for the current head.
  • Overlap: #16654 also implements BIO_vfree in libSceLibreSsl3 (src/BioLifetime.cpp). The "no other open PR implements the same functions" box is therefore false. Either drop BIO_vfree here and keep BIO_printf (and list #16654 under Depends on if you need it), or agree with that PR which one lands.
  • core/libs/prx/libSceLibreSsl/Export.cpp:42-44: writeFormatted returns -1 when BIO_write returns fewer bytes than formatted. LibreSSL's BIO_vprintf returns what BIO_write returns. Return that value, or record the deviation in docs/dev/debt/libSceLibreSsl.md, and add a test with a BIO whose write is short.
  • core/libs/prx/libSceLibreSsl3/Export.cpp:16-19: the callback branch (callback(bio, 1, ...), return when the result is <= 0) has no test, and the body says a BIO with a callback throws. Cover both results and make the body match the code.
  • The _WIN32 branch of BIO_printf_nid_postfix (__builtin_sysv_va_list) has no Windows run on this head; a rerun of the Windows check from @JJenkx would settle it.

Welcome back once these are addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5847416789 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16529#pullrequestreview-5847416789). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-10T18:43:18Z. **Review:** CHANGES_REQUESTED --- Checked the diff against the PR thread and #16654. Needs a few changes: - The PR body no longer matches the diff: it describes 19 exports (`BIO_meth_*`, `BN_dup`, `BN_div`, `BN_print`, ...) and tests that are not in this head. The diff only implements `BIO_printf` and `BIO_vfree`. Please rewrite What/Tested for the current head. - Overlap: #16654 also implements `BIO_vfree` in `libSceLibreSsl3` (`src/BioLifetime.cpp`). The "no other open PR implements the same functions" box is therefore false. Either drop `BIO_vfree` here and keep `BIO_printf` (and list #16654 under Depends on if you need it), or agree with that PR which one lands. - `core/libs/prx/libSceLibreSsl/Export.cpp:42-44`: `writeFormatted` returns -1 when `BIO_write` returns fewer bytes than formatted. LibreSSL's `BIO_vprintf` returns what `BIO_write` returns. Return that value, or record the deviation in `docs/dev/debt/libSceLibreSsl.md`, and add a test with a BIO whose write is short. - `core/libs/prx/libSceLibreSsl3/Export.cpp:16-19`: the callback branch (`callback(bio, 1, ...)`, return when the result is <= 0) has no test, and the body says a BIO with a callback throws. Cover both results and make the body match the code. - The `_WIN32` branch of `BIO_printf_nid_postfix` (`__builtin_sysv_va_list`) has no Windows run on this head; a rerun of the Windows check from @JJenkx would settle it. Welcome back once these are addressed.
adriadam10 commented 2026-11-10 23:09:17 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-10T23:09:17Z.

Review: CHANGES_REQUESTED


Thanks for the update; the short-write return and the BIO_vfree callback tests address two of the earlier points. Still open:

  • The PR body still describes 19 exports (BIO_meth_*, BN_dup, BN_div, BN_print, ...) and tests (guest_libressl3_bio, guest_libressl3_bignum) that are not in this head. The diff implements only BIO_printf and BIO_vfree. Please rewrite What/Tested for the current head.
  • Overlap: #16654 (open) also implements BIO_vfree in libSceLibreSsl3, so "no other open PR implements the same functions" is still false. Either drop BIO_vfree here and keep BIO_printf, or agree with that PR which one lands and list it under Depends on.
  • The windows check is red on this head; please look at whether it comes from the _WIN32 __builtin_sysv_va_list branch of BIO_printf_nid_postfix (core/libs/prx/libSceLibreSsl/Export.cpp:58-62).

Welcome back once these are addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5850916924 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16529#pullrequestreview-5850916924). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-10T23:09:17Z. **Review:** CHANGES_REQUESTED --- Thanks for the update; the short-write return and the BIO_vfree callback tests address two of the earlier points. Still open: - The PR body still describes 19 exports (`BIO_meth_*`, `BN_dup`, `BN_div`, `BN_print`, ...) and tests (`guest_libressl3_bio`, `guest_libressl3_bignum`) that are not in this head. The diff implements only `BIO_printf` and `BIO_vfree`. Please rewrite What/Tested for the current head. - Overlap: #16654 (open) also implements `BIO_vfree` in `libSceLibreSsl3`, so "no other open PR implements the same functions" is still false. Either drop `BIO_vfree` here and keep `BIO_printf`, or agree with that PR which one lands and list it under Depends on. - The `windows` check is red on this head; please look at whether it comes from the `_WIN32` `__builtin_sysv_va_list` branch of `BIO_printf_nid_postfix` (`core/libs/prx/libSceLibreSsl/Export.cpp:58-62`). Welcome back once these are addressed.
adriadam10 commented 2026-11-12 20:32:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-12T20:32:25Z.

Review: CHANGES_REQUESTED


Thanks for the rebase. The windows check is green now and the code is unchanged; two earlier points are still open, plus one new one:

  • The PR body still describes 19 exports (BIO_meth_*, BN_dup, BN_div, BN_print, ...) and tests (guest_libressl3_bio, guest_libressl3_bignum) that are not in this head. The diff implements only BIO_printf and BIO_vfree. Please rewrite What/Tested for the current head.
  • Overlap: #16654 (open) also implements BIO_vfree in libSceLibreSsl3, so "no other open PR implements the same functions" is still false. Either drop BIO_vfree here and keep BIO_printf, or agree with that PR which one lands and list it under Depends on.
  • docs/dev/debt/libSceLibreSsl3.md:27 still says "42 named callable exports" although BIO_vfree is no longer a stub; lower the count by one or list BIO_vfree among the exclusions (unless it is dropped from this PR).

Welcome back once these are addressed.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5881580101 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16529#pullrequestreview-5881580101). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-11-12T20:32:25Z. **Review:** CHANGES_REQUESTED --- Thanks for the rebase. The `windows` check is green now and the code is unchanged; two earlier points are still open, plus one new one: - The PR body still describes 19 exports (`BIO_meth_*`, `BN_dup`, `BN_div`, `BN_print`, ...) and tests (`guest_libressl3_bio`, `guest_libressl3_bignum`) that are not in this head. The diff implements only `BIO_printf` and `BIO_vfree`. Please rewrite What/Tested for the current head. - Overlap: #16654 (open) also implements `BIO_vfree` in `libSceLibreSsl3`, so "no other open PR implements the same functions" is still false. Either drop `BIO_vfree` here and keep `BIO_printf`, or agree with that PR which one lands and list it under Depends on. - `docs/dev/debt/libSceLibreSsl3.md:27` still says "42 named callable exports" although `BIO_vfree` is no longer a stub; lower the count by one or list `BIO_vfree` among the exclusions (unless it is dropped from this PR). Welcome back once these are addressed.
ligmaSec commented 2026-12-03 15:16:37 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T15:16:37Z.

Review: COMMENTED


I ran guest_libressl_bio with the patch applied on Linux. It passed the formatted-write cases, including empty output, formatting beyond the stack buffer, read-only failure, and preserving the short-write count from BIO_write.

AI-assisted: yes.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:6172664493 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16529#pullrequestreview-6172664493). Originally posted by [ligmaSec](https://github.com/ligmaSec) on 2026-12-03T15:16:37Z. **Review:** COMMENTED --- I ran `guest_libressl_bio` with the patch applied on Linux. It passed the formatted-write cases, including empty output, formatting beyond the stack buffer, read-only failure, and preserving the short-write count from `BIO_write`. 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/16529:upstream-pr/16529'
git switch 'upstream-pr/16529'

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