fix(libSceWebBrowserDialog): return ARG_NULL from result and cookie operations for unwritable pointers #16049

Merged
pushkarreddyy merged 3 commits from upstream-pr/16049 into main 2026-11-08 16:36:36 +00:00
pushkarreddyy commented 2026-11-05 13:01:25 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by pushkarreddyy on 2026-11-05T13:01:25Z.


What

In core/libs/prx/libSceWebBrowserDialog/Export.cpp, sceWebBrowserDialogGetResult, sceWebBrowserDialogSetCookie, and sceWebBrowserDialogResetCookie directly dereferenced caller-supplied pointer arguments (result->reserved, result->extended, result->result, param->size, etc.) without verifying memory readability or writability. When a guest title passed an unwritable or unmapped pointer (e.g. 0x10), host memory access triggered an unhandled fault.

  • Validated memory accessibility and safely copied guest buffers using GuestCopyIn_nid_no_patch and GuestCopyOut_nid_no_patch in sceWebBrowserDialogGetResult, sceWebBrowserDialogSetCookie, and sceWebBrowserDialogResetCookie.
  • Safely checked string readability in LengthWithin before computing string lengths.
  • Returned COMMON_DIALOG_ERROR_ARG_NULL (0x80B8000D) when guest pointer access fails as a host-safety fallback.
  • Added comprehensive unit test coverage in core/libs/tests/GuestWebBrowserDialog.cpp asserting COMMON_DIALOG_ERROR_ARG_NULL and COMMON_DIALOG_ERROR_PARAMETER on invalid pointers.
  • Documented the host-safety fallback contract in docs/dev/debt/libSceWebBrowserDialog.md.

Fixes: #16044

Tested

  • Ran python tools/check_conventions.py --base origin/main with 0 findings.
  • Added test coverage in core/libs/tests/GuestWebBrowserDialog.cpp verifying invalid pointer handling in result, extended result, cookie param, address, and reset cookie queries.

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: #16044
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5171981878 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16049). Originally posted by [pushkarreddyy](https://github.com/pushkarreddyy) on 2026-11-05T13:01:25Z. --- ### What In `core/libs/prx/libSceWebBrowserDialog/Export.cpp`, `sceWebBrowserDialogGetResult`, `sceWebBrowserDialogSetCookie`, and `sceWebBrowserDialogResetCookie` directly dereferenced caller-supplied pointer arguments (`result->reserved`, `result->extended`, `result->result`, `param->size`, etc.) without verifying memory readability or writability. When a guest title passed an unwritable or unmapped pointer (e.g. `0x10`), host memory access triggered an unhandled fault. - Validated memory accessibility and safely copied guest buffers using `GuestCopyIn_nid_no_patch` and `GuestCopyOut_nid_no_patch` in `sceWebBrowserDialogGetResult`, `sceWebBrowserDialogSetCookie`, and `sceWebBrowserDialogResetCookie`. - Safely checked string readability in `LengthWithin` before computing string lengths. - Returned `COMMON_DIALOG_ERROR_ARG_NULL` (`0x80B8000D`) when guest pointer access fails as a host-safety fallback. - Added comprehensive unit test coverage in `core/libs/tests/GuestWebBrowserDialog.cpp` asserting `COMMON_DIALOG_ERROR_ARG_NULL` and `COMMON_DIALOG_ERROR_PARAMETER` on invalid pointers. - Documented the host-safety fallback contract in `docs/dev/debt/libSceWebBrowserDialog.md`. Fixes: #16044 ### Tested - Ran `python tools/check_conventions.py --base origin/main` with 0 findings. - Added test coverage in `core/libs/tests/GuestWebBrowserDialog.cpp` verifying invalid pointer handling in result, extended result, cookie param, address, and reset cookie queries. ### Checklist - [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: #16044 - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
mashingaan commented 2026-11-07 11:37:54 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by mashingaan on 2026-11-07T11:37:54Z.

Review: APPROVED


The copy-in/out routing covers the result, cookie, reset-cookie, open and allow-list paths, and the byte-wise LengthWithin reads through GuestCopyIn. The invalid-pointer tests cover each entry point. No findings.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5811956449 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/16049#pullrequestreview-5811956449). Originally posted by [mashingaan](https://github.com/mashingaan) on 2026-11-07T11:37:54Z. **Review:** APPROVED --- The copy-in/out routing covers the result, cookie, reset-cookie, open and allow-list paths, and the byte-wise LengthWithin reads through GuestCopyIn. The invalid-pointer tests cover each entry point. No findings.
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!16049
No description provided.