Commit Graph
587 Commits
Author SHA1 Message Date
Henrik Rydgård b7b96c3374 Fix LZRC decompressor heap overflow and add unit test
The LZRC decompressor's only bounds check for output (and input) was a
debug-only _dbg_assert_msg_, which is a no-op in release builds. The
NPDRM demo block device also passed a hardcoded 1 MiB output length
while the real destination buffer (blockBuf_) could be as small as 2048
bytes, allowing a crafted NPDRM image to trigger an unbounded heap
overflow during game load.

Changes:
- rc_putbyte/rc_getbyte now enforce real bounds and set an error flag
  instead of relying on debug asserts; decompression aborts with -1 on
  overflow or truncated input.
- normalize() reads via rc_getbyte so it stays in bounds.
- Plain-text path clamps the copy size to both the output buffer and the
  remaining input (and no longer interprets the size as signed).
- NPDRMDemoBlockDevice::ReadBlock passes blockSize_ (the real buffer
  size) instead of 0x00100000 to lzrc_decompress.
- Add unittest/TestLzrc (synthetic input, no test data files): checks the
  plain-text clamp, truncated input, and output overflow all fail safely.
- AGENTS.md: note to reuse existing format handlers/decompressors before
  writing new ones.
2026-07-31 20:54:13 +02:00
Henrik Rydgård e806192154 Delete the ability to load file handler plugins from extracted game folders
If there's demand for this feature, we'll bring it back and put it
behind a developer option.

Fixes vuln #7 from the recent collection
2026-07-31 20:35:12 +02:00
Henrik Rydgård 6fb48fd45a Fix heap buffer overflow in CSO block device from crafted index table
A crafted .cso compressed ISO could trigger a heap buffer overflow on any
sector read, reachable via ordinary gameplay.

Two root causes:
1. Unvalidated frame index deltas. ReadBlock/ReadBlocks computed a
   compressed read range from two adjacent frame-index-table entries.
   With non-monotonic entries, compressedReadEnd - compressedReadPos
   underflows as u64, producing a huge read size that fileLoader->ReadAt()
   wrote into the fixed-size readBuffer.
2. hdr.align (indexShift, 0-255) used as '1 << indexShift' was undefined
   behavior at >= 32, and frameSize + (1 << indexShift) could wrap,
   undersizing the buffer while inflate() was configured with the full
   frameSize.

Fixes:
- Validate the index table is monotonically non-decreasing in the
  constructor.
- Reject files with indexShift > 20.
- Use unsigned shift for buffer size math and store readBufferSize.
- Clamp compressed read sizes to readBufferSize in both ReadBlock and
  ReadBlocks.
2026-07-31 20:35:12 +02:00
Henrik Rydgård 4bf36fc7f8 Add command line option --vsh to try to boot the VSH. Logspam reduction, improve printf logs. 2026-07-27 14:58:59 +02:00
Henrik Rydgård 2d8de4c1bf Improve error checking on game launch.
See #21886
2026-07-08 12:04:15 +02:00
Henrik Rydgård e9d5e451fb Avoid some unnecessary error reporting while loading ISOs for the file browser 2026-05-31 23:31:06 +02:00
Henrik Rydgård 7309c477d1 Logging change 2026-05-28 10:55:24 +02:00
Henrik Rydgård 935a50ac59 ISO file system: Clean out version numbers from filenames.
Followup to #21599
2026-04-27 12:36:58 +02:00
whatev.indus f73b27c69d Support loading PSP prototype DVD-R disc dumps directly
Some preserved PSP prototype builds were distributed as DVD-R images that contain the actual UMD data inside USER_L0.IMG and, for dual-layer titles, USER_L1.IMG. These images previously required manual extraction, renaming, or concatenation before PPSSPP could load them.

Add support for recognizing these DVD-R wrapper layouts and exposing the embedded UMD image through the normal disc loading path. This includes both ISO-based wrappers and UDF-based wrappers, so preserved prototype dumps can be opened directly without conversion.

This makes PPSSPP compatible with a wider range of preserved developer disc images without relying on title-specific handling.

The primary importance of this patch is to encourage preserving 1:1, perfect disc image dumps in the manner of Redump.org.

This patch has been successfully tested on the following DVD-R ISOs:
https://hiddenpalace.org/Rock_Band_Unplugged_(Dec_10,_2008_prototype)
https://hiddenpalace.org/WipEout_Pulse_(May_4,_2007_prototype)
https://hiddenpalace.org/Lara_Croft_Tomb_Raider:_Anniversary_(May_19,_2007_prototype)
https://hiddenpalace.org/Heatseeker_(Jan_15,_2007_prototype)

Fixes #15547.
2026-04-26 19:44:49 -07:00
Henrik Rydgård b8463b9203 Fix assorted warnings, bump Cargo.lock 2026-03-24 10:26:49 -06:00
Henrik Rydgård 6377c0bb06 Implement optional dumping of NPDRM isos (PBP demos) on game startup 2026-03-19 16:07:24 +01:00
Henrik Rydgård 0e55129fab Prepare for dumping NPDRM isos, use shared_ptr to manage lifetime of BlockDevice 2026-03-19 13:59:04 +01:00
Henrik Rydgård e5a226a309 Correct bugs in CSO reader 2026-02-26 10:37:12 +01:00
Henrik Rydgård b7ad74d309 MetaFileSystem: Turn another argument into string_view 2026-02-25 00:52:25 +01:00
Henrik Rydgård 22bfa0087c Minor code cleanup 2026-02-25 00:52:25 +01:00
Henrik Rydgård dac2407a36 sceIo: Add support for microseconds in filetimes (not implemented in platforms yet) 2026-02-23 11:04:17 +01:00
Henrik Rydgård b75c416bc1 Some error message cleanup 2026-02-18 14:42:41 +01:00
Henrik Rydgård 19a0441299 Fix crash in NPDRM iso detection (by rejecting invalid values and checking the header) 2026-02-17 15:27:56 +01:00
Henrik Rydgård f8077347e4 FileSystems: Change multiple internal functions to take std::string_view 2026-02-06 12:31:49 +01:00
Henrik Rydgård c85496c84d ISOFileSystem: Some const correctness 2026-02-06 12:00:53 +01:00
Henrik Rydgård f2116c4236 Start using string_view in MetaFileSystem 2026-02-06 11:51:40 +01:00
Henrik Rydgård 841e4c8564 Add various checks trying to avoid various crashes found in Google Play crash reports. 2026-02-05 11:12:53 +01:00
Henrik Rydgård 4fb3a0e370 Bubble up more error messages to the user 2026-01-29 00:25:25 +01:00
Henrik Rydgård 24f2deeb2e Improve file identification.
Fixes #21154
2026-01-28 10:21:09 +01:00
刘皓 295ac0e9f6 Merge branch 'master' into libretro-vfs 2026-01-02 12:58:27 -05:00
刘皓 5716cbd41d Use the libretro VFS interface in libretro builds 2026-01-01 00:24:01 -05:00
Henrik Rydgård 5f7a937466 Rename ValidSize to ClampValidSizeAt 2025-12-30 20:31:07 +01:00
Henrik Rydgård 64680a4ebf Add early checks in the various BlockDevice implementations 2025-06-07 12:30:20 +02:00
Henrik Rydgård 77f9a27c35 Add a way for errors to bubble up out of BlockDevice creation 2025-06-07 12:30:20 +02:00
Henrik Rydgård c29e370e29 Remove global state from kirk engine 2025-06-05 22:46:24 +02:00
Henrik Rydgård 6bf8d7d1db Memory safety fixes 2025-05-22 11:10:00 +02:00
Henrik Rydgård dbe6ec80a0 Fix some bad "for (auto x : y)" usage 2025-04-29 16:46:14 +02:00
Henrik Rydgård 08d1e0b3d8 Logspam cleanup 2025-04-17 11:06:06 +02:00
Henrik Rydgård 41b77bf1ae More log cleanup 2025-04-14 22:27:51 +02:00
Henrik Rydgård fffbed53bc Add a ZipFileLoader, which can let us load any single-file file type from a zip.
Useful for loading framedumps from github without manually having to
unzip each one, for example.
2025-04-12 22:23:23 +02:00
Henrik Rydgård d5fe826acc Linux buildfix 2025-03-30 15:28:47 +02:00
Henrik Rydgård 05b1cf3b80 Startup cleanup, part 1 2025-03-26 09:24:14 +01:00
Henrik Rydgård 0f840e6240 Move JPEG error codes to the big enum, some include cleanup 2025-03-21 20:44:46 +01:00
Henrik Rydgård ef386ac4c5 Add "GetFileInfoByHandle" function to (many) file systems 2025-03-19 10:42:30 +01:00
Henrik Rydgård 2cc631338b Correctly unload GE framedumps. Additionally, look up the title when possible and show in titlebar. 2025-03-06 14:58:33 +01:00
Henrik Rydgård 3ab625a0fa Windows: Lock when updating the window title 2025-03-06 14:24:40 +01:00
Henrik Rydgård 7e3e944e3b Update GetSecondBufferInfo 2025-03-05 17:02:46 +01:00
Henrik Rydgård c6691de64c Remove excessive error reporting 2025-03-02 02:28:42 +01:00
oltolm f11674b2d6 get rid of more __MINGW32__ ifdefs 2025-01-19 10:33:22 +01:00
Henrik Rydgård 6cae2df12d UWP buildfix 2025-01-02 19:52:51 +01:00
Henrik Rydgård 55aef2afdb Check file systems for case sensitivity. Avoid running un-needed workarounds. 2025-01-02 18:50:55 +01:00
Henrik Rydgård 92e7a28d98 Fix two edge cases in path mapping on scoped storage.
Fixes #19788
2025-01-02 17:41:52 +01:00
Henrik Rydgård c91169e702 Restore removed <algorithm> includes.
Turns out these were needed after all. For some reason, on Windows and
Mac, <algorithm> gets auto-included by something else so I don't notice
when it's missing, and MSVC's include dependency tracker doesn't see it
either.
2024-12-19 09:53:07 +01:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård 7e194d15e2 For the free-space savedata scan, only scan relevant subdirectories. 2024-11-29 15:34:22 +01:00