Commit Graph
111 Commits
Author SHA1 Message Date
Zulux91 20c854aeb3 patch_engine: stop save_patches from destroying the file it rewrites
Two defects on the same write path, both reachable today from Download
database and from a local patch import.

1. The file was opened with fs::rewrite (write + create + trunc), streamed
   into, and the write result discarded -- save_patches returned true
   unconditionally. A write that fails part way (out of space, process
   killed) therefore leaves a truncated patch.yml behind, and load() rejects
   the whole file on a parse error, so the failure costs the user every patch
   they had. There is no way to rebuild it from inside the app either:
   import_patches refuses to write when load() fails, so both import paths
   return -1 from then on.

   save_config, 70 lines up in the same file, already writes through
   fs::pending_file and checks the result. save_patches now does the same.

2. The address element was always emitted as fmt::format("0x%.8x", offset).
   For move_file and hide_file that element is a VFS path, not a number:
   load() keeps the text in original_offset and skips the u32 validation for
   those two types. So a round trip turned a path into 0x00000000, and the
   loader accepted it back -- the patch still lists and still toggles, it just
   silently stops matching anything. Re-downloading does not repair it,
   because append_patches discards an incoming patch whose Patch Version is
   not strictly greater than the stored one.

   The emit is now gated on patch_type_uses_hex_offset, the predicate that
   already existed for this and was used only on the load side.

   The numeric branch deliberately keeps using offset rather than
   original_offset: an address modifier is folded into offset at load time,
   and the flat form emitted here has nowhere to put it.

Both predate the Android patch work and apply to upstream RPCS3 unchanged;
they are in this branch because the bundled-patch import adds another caller
of save_patches.

Verified on device (arm64, Android 15). A patch.yml seeded with move_file and
hide_file entries was put through an import that merges a new patch, which is
what forces the rewrite. After it:

  - [move_file, /dev_bdvd/PS3_GAME/USRDIR/probe.bik, /dev_bdvd/PS3_GAME/USRDIR/probe.bik.bak]
  - [hide_file, /dev_bdvd/PS3_GAME/USRDIR/hidden.bik, ""]

Both paths survived; before this change they would read 0x00000000. All three
top-level hashes in the file (the two seeded, plus the merged one) were still
present and parseable afterwards.

Not verified: the failure path in (1). Forcing a short write mid-rewrite
(ENOSPC or a kill inside save_patches) was not exercised, so the atomicity is
argued from fs::pending_file's contract and from parity with save_config, not
from a reproduced failure.
2026-08-17 03:20:43 -05:00
RipleyTom 5ca19eabd5 NP code review
sceNpTrophy fixes

- sceNpTrophyGetTrophyUnlockState: signed 1 was potentially shifted by 31(UB)
- sceNpTrophyUnlockTrophy: used a reader_lock and was missing check for read only context

cellGame fixes

- cellHddGameCheck: missing log parameters
- cellGameDataCheckCreate2: missing log parameter
- cellGameThemeInstall: condition inverted checking for extension + added tolower just in case
- cellGameThemeInstallFromBuffer: OOB access, buf is always filled from the start and then used as a parameter to the CB

sceNp fixes

- sceNpManagerGetTicket: Made accurate from RE
- sceNpDrmGetTimelimit: Fix msec calculation

sceNp2 fixes

-sceNpMatching2ContextStartAsync: avoid capturing ctx
-sceNpMatching2ContextStop: Minor error value swap

rpcn_client fixes

-add_friend: missing log parameter
-handle_friend_notification: misc validation issue

np_handler fixes
-ticket: Missing move in move constructor
-ticket::parse: Misc validation fix
-get_player_history_entry: potential UB fix

np_requests fixes

-Wrong CB event_type set for get_room_member_data_external_list!
-reply_tus_get_data was not copying status data!
-Order of error check in reply_get_room_member_data_external_list was wrong
-Improved logging

np_requests_gui:

-Added missing guards for gui_notifications

upnp_handler fixes

-Highest density of bugs per line of code in the west, let's pretend I never wrote this

signaling_handler fixes

-Swapped to multimap to avoid collisions on timestamps

Misc fixes
2026-03-01 09:20:32 +02:00
Megamouse 1960b5a605 hotfix: fix parentheses when saving some files 2025-04-23 16:27:17 +02:00
Megamouse 22c184bf75 cellMusic: improve logging 2025-04-23 08:14:59 +02:00
Megamouse faef63e8a7 patches: fix c_utf8 validation 2025-03-24 21:44:23 +01:00
Megamouse 451e953d26 windows: move config.yml and games.yml to /config/ 2025-01-16 21:33:33 +01:00
Elad c6f3737c2a PPU LLVM: Fixup patches enlisting in analyzer 2025-01-07 20:42:45 +02:00
Elad 0b784ff2c1 PPU LLVM: Function table dependent resolver hashing 2025-01-07 15:43:41 +02:00
oltolm 2b0f786b2d Fix std::basic_string warnings (#16261) 2024-11-11 21:54:44 +02:00
kd-11 c80342e8d4 aarch64: Support calloc patch blocks 2024-08-31 13:55:58 +03:00
Megamouse 456ff10f02 Qt/patches: don't allow duplicate app versions 2024-08-15 09:35:58 +02:00
Megamouse 8371c445ce Qt/patches: check if app version is 5 characters long and like 01.00 2024-08-15 09:35:58 +02:00
Megamouse 93424d1adc Qt/patches: check if serial is 9 characters long and alphanumeric 2024-08-15 09:35:58 +02:00
Megamouse d05d803f5e patches: use more std::move 2024-08-15 09:35:58 +02:00
Megamouse 76c0df849a patches: improve error logging: add file paths to all errors 2024-08-14 20:21:55 +02:00
Megamouse 4051988403 Qt/patches: improve value validation 2024-08-14 20:21:55 +02:00
Megamouse 59c58aa3cf fix some warnings 2023-12-30 19:07:35 +01:00
Eladash e79fc867c5 Patches: Add savable breakpoints patch type 2023-09-26 11:06:01 +03:00
Megamouse f199ad7a42 patches: Improve location logging for invalid note sequence 2023-08-12 14:43:47 +02:00
Megamouse d119cf6e96 Qt6 port 2023-07-31 20:03:24 +03:00
oltolm bc40b61ef1 rename fs::stat to fs::get_stat 2023-07-25 12:15:08 +03:00
Eladash 95fb7859d2 Fixup patches 2023-07-24 17:07:15 +03:00
Megamouse 3381144d2e Patches: improve location logging of some invalid nodes 2023-07-13 08:40:19 +02:00
Megamouse a19883f875 Patches: do not allow empty patch names 2023-07-13 08:40:19 +02:00
Megamouse 02bac61c9c Patches: validate yml patch offset values 2023-07-13 08:40:19 +02:00