feat(libSceFreeTypeOt): read Mac resource fork headers and data offsets #15050

Merged
noamroger merged 2 commits from upstream-pr/15050 into main 2026-11-05 08:46:49 +00:00
noamroger commented 2026-11-02 12:33:32 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by noamroger on 2026-11-02T12:33:32Z.


What

Implements two of the three Mac resource fork exports of libSceFreeTypeOt, FT_Raccess_Get_HeaderInfo (p5GNJaXO2yE) and FT_Raccess_Get_DataOffsets (hF3stKUWbWg), which were sceFreeTypeOtUnknown_* stubs. Both follow FreeType 2.4.12 src/base/ftrfork.c on the existing Ot streams (FT_Stream_Seek/Read/Skip/ReadUShort/ReadLong) and ft_mem_realloc/ft_mem_free, so the guest memory callbacks see the same allocations as in FreeType (16-byte reference array, freed; FT_Long offsets array, returned to the caller).

The Ot exports already date this FreeType to 2.4.11-2.4.12 (FT_Sqrt32, FT_Property_Set), so FT_Raccess_Get_DataOffsets takes the seven arguments of that version; sort_by_res_id only appeared in 2.5.3. That risk, the inputs where 2.4.12 has undefined behaviour (header field with the top bit set, FT_Long overflow) and duplicate resource IDs with different offsets (unspecified ft_qsort order) throw and are recorded in docs/dev/debt/libSceFreeTypeOt.md. FT_Raccess_Guess (8cnVx1yH9-I) keeps throwing: it opens sibling files through path rules.

Tested

Linux (Ubuntu 24.04, g++ 13): new GuestFreeTypeOtRaccess test built against Stream.cpp, src/Memory.cpp and src/Raccess.cpp, also with -fsanitize=address,undefined: fork at offset 0 and 0x80 with a copied and a zeroed map header, references sorted by ID with the attribute byte dropped, missing tag (Cannot_Open_Resource, nothing written or allocated), data/map length mismatch, mismatching map header and empty map (Unknown_File_Format, rdata_pos written first as in FreeType), short and out-of-range streams (Invalid_Stream_Operation), and a cut reference list (count written, reference array freed). tools/check_conventions.py --base upstream/main and test_public_headers.py --audit-only pass. tools/pr_overlap.py cannot reach the GitHub API from my environment; I checked by NID that no open pull request changes p5GNJaXO2yE, hF3stKUWbWg or 8cnVx1yH9-I.

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:5120378630 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/15050). Originally posted by [noamroger](https://github.com/noamroger) on 2026-11-02T12:33:32Z. --- ### What Implements two of the three Mac resource fork exports of libSceFreeTypeOt, `FT_Raccess_Get_HeaderInfo` (`p5GNJaXO2yE`) and `FT_Raccess_Get_DataOffsets` (`hF3stKUWbWg`), which were `sceFreeTypeOtUnknown_*` stubs. Both follow FreeType 2.4.12 `src/base/ftrfork.c` on the existing Ot streams (`FT_Stream_Seek/Read/Skip/ReadUShort/ReadLong`) and `ft_mem_realloc`/`ft_mem_free`, so the guest memory callbacks see the same allocations as in FreeType (16-byte reference array, freed; `FT_Long` offsets array, returned to the caller). The Ot exports already date this FreeType to 2.4.11-2.4.12 (`FT_Sqrt32`, `FT_Property_Set`), so `FT_Raccess_Get_DataOffsets` takes the seven arguments of that version; `sort_by_res_id` only appeared in 2.5.3. That risk, the inputs where 2.4.12 has undefined behaviour (header field with the top bit set, `FT_Long` overflow) and duplicate resource IDs with different offsets (unspecified `ft_qsort` order) throw and are recorded in `docs/dev/debt/libSceFreeTypeOt.md`. `FT_Raccess_Guess` (`8cnVx1yH9-I`) keeps throwing: it opens sibling files through path rules. ### Tested Linux (Ubuntu 24.04, g++ 13): new `GuestFreeTypeOtRaccess` test built against `Stream.cpp`, `src/Memory.cpp` and `src/Raccess.cpp`, also with `-fsanitize=address,undefined`: fork at offset 0 and 0x80 with a copied and a zeroed map header, references sorted by ID with the attribute byte dropped, missing tag (Cannot_Open_Resource, nothing written or allocated), data/map length mismatch, mismatching map header and empty map (Unknown_File_Format, `rdata_pos` written first as in FreeType), short and out-of-range streams (Invalid_Stream_Operation), and a cut reference list (count written, reference array freed). `tools/check_conventions.py --base upstream/main` and `test_public_headers.py --audit-only` pass. `tools/pr_overlap.py` cannot reach the GitHub API from my environment; I checked by NID that no open pull request changes `p5GNJaXO2yE`, `hF3stKUWbWg` or `8cnVx1yH9-I`. ### 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)
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!15050
No description provided.