fix(libkernel): preserve 64-bit metadata download sizes #661

Merged
NumberGuan merged 1 commit from upstream-pr/661 into main 2026-10-05 19:03:11 +00:00
NumberGuan commented 2026-10-05 12:13:40 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by NumberGuan on 2026-10-05T12:13:40Z.


What

parseParamJson converts downloadDataSize through double, which changes large integer values. For example, 9007199254740993 becomes 9007199254740992. Converting an out-of-range floating-point value to uint64_t also has undefined behavior in C++.

Keep the numeric token and parse unsigned integer literals directly with std::from_chars. Values through UINT64_MAX remain exact, and larger integers throw. Decimal and exponent forms retain their existing conversion behavior, with a range check before the cast.

Add a test linked against libkernel for omitted and zero sizes, normal sizes, integers above the exact range of double, both upper uint64 boundaries, decimal/exponent compatibility, overflow, negative values, and invalid JSON value types.

Tested

Windows, Release, WinLibs GCC 15.2.0 UCRT POSIX:

cmake --build build --target param_json_parser_tests guest_filesystem_tests --parallel 4
ctest --test-dir build -R '^(param_json_parser|guest_filesystem)$' --output-on-failure --no-tests=error

Both tests passed. The new regression test failed on the original code at 9007199254740993. No title or homebrew was run. Linux and the full suite were not run locally.

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 added in code
  • Unimplemented paths throw; no silent stubs added
  • No investigation files or images added
  • No third-party code added
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes, Codex
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4744724781 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/661). Originally posted by [NumberGuan](https://github.com/NumberGuan) on 2026-10-05T12:13:40Z. --- ### What `parseParamJson` converts `downloadDataSize` through `double`, which changes large integer values. For example, `9007199254740993` becomes `9007199254740992`. Converting an out-of-range floating-point value to `uint64_t` also has [undefined behavior in C++](https://eel.is/c++draft/conv.fpint). Keep the numeric token and parse unsigned integer literals directly with `std::from_chars`. Values through `UINT64_MAX` remain exact, and larger integers throw. Decimal and exponent forms retain their existing conversion behavior, with a range check before the cast. Add a test linked against `libkernel` for omitted and zero sizes, normal sizes, integers above the exact range of `double`, both upper uint64 boundaries, decimal/exponent compatibility, overflow, negative values, and invalid JSON value types. ### Tested Windows, Release, WinLibs GCC 15.2.0 UCRT POSIX: ```text cmake --build build --target param_json_parser_tests guest_filesystem_tests --parallel 4 ctest --test-dir build -R '^(param_json_parser|guest_filesystem)$' --output-on-failure --no-tests=error ``` Both tests passed. The new regression test failed on the original code at `9007199254740993`. No title or homebrew was run. Linux and the full suite were not run locally. ### 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 added in code - [x] Unimplemented paths throw; no silent stubs added - [x] No investigation files or images added - [x] No third-party code added - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes, Codex
github-actions[bot] commented 2026-10-05 18:14:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-05T18:14:53Z.


Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
#710 core/libs/tests/ParamJsonParser.cpp core/libs/tests/ParamJsonParser.cpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6000382325 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/661#issuecomment-6000382325). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-05T18:14:53Z. --- <!-- pr-overlap --> Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in **Depends on**. | Pull request | Conflicting files (lines on `main`) | Same exports | Same new files | |---|---|---|---| | #710 | `core/libs/tests/ParamJsonParser.cpp` | | `core/libs/tests/ParamJsonParser.cpp` |
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!661
No description provided.