Commit Graph
54 Commits
Author SHA1 Message Date
a-blondel 4b324b278a Strip spaces of the disc ID 2026-08-28 22:36:59 +02:00
Henrik Rydgård e9cdb2b20f UI work for VSH (Windows and ImGui) 2026-08-24 11:13:00 +02:00
Henrik RydgårdandClaude Opus 5 5020647bab PBPReader: detect ELFs by their actual magic, and sanity-check subfile sizes
The "is this an ELF rather than a PBP" test compared against "\nFLE", which is
neither ELF's magic (\x7fELF) nor anything else - most likely a \x7f escape that
swallowed the E when it was written in 2013. Since no real file matches it,
every file that wasn't a PBP was reported as an ELF and the error branch was
unreachable. Compares against the real magic now, so something that's neither is
reported as neither. That error also printed the 4-byte magic with %s, which
isn't NUL-terminated - it's four hex bytes instead.

GetSubFileSize subtracted offsets that come straight out of the file without
checking they're ordered or even inside it, so a corrupt PBP produced a size
from an unsigned underflow - nearly 4GB, which the callers then had to catch by
size limit. It returns 0 for anything that doesn't make sense.

Also &(*out)[0] on a zero-length subfile, which is UB on an empty vector.

Plus one in ParamSFO: GetDataOffset mixed int and u32 for the data offset, so
its bounds check ran in whichever type the promotion landed on. It's size_t
throughout now, matching how ReadSFO does the same arithmetic.

Booted an EBOOT.PBP to check the PBP path end to end - loads, and generates the
same fake disc ID as before. pspautotests 314/314, UnitTest 55/55.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 19:19:06 +02:00
Henrik RydgårdandClaude Opus 5 90a178aeb8 ParamSFO: make GenerateFakeID independent of char signedness
The fake disc ID homebrew gets when it has no PARAM.SFO is built from the sum of
the bytes of its folder name, summed through a plain char - which is signed on
x86 and unsigned on ARM. So the same homebrew folder produced one ID on Windows
and a different one on Android, quietly splitting its savestates and per-game
config between platforms. Sum through unsigned char, which is what the ARM
builds (Android, iOS, Apple Silicon) already did.

Uppercasing is now explicit and ASCII-only rather than toupper(). Passing a
negative char to toupper() is undefined and trips MSVC's debug CRT assert, so a
folder with a non-ASCII name could stop a debug build dead, and what it did with
bytes above 0x7F otherwise depended on the locale.

ASCII folder names - very nearly all of them - produce exactly the same ID as
before. Non-ASCII ones change on the signed-char platforms, to what the
unsigned-char ones were already generating.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 19:19:06 +02:00
Henrik RydgårdandClaude Opus 5 077205da9b ParamSFO: stop WriteSFO writing past the space an entry reserved
Each entry gets param_max_len bytes in the data table, and that's what the
buffer is sized from - but nothing clamped what got written into it.

For VT_UTF8 the length written was s_value.size()+1, and then a terminator was
stored at data_ptr[param_len], one byte beyond that again. The memcpy already
copies the terminator (param_len counts it), so that store was both redundant
and always out of range. It doesn't take a malformed file to hit: several
callers pass the string's own length as max_size - see PSPLoaders.cpp's TITLE,
DISC_ID and DISC_VERSION - so the entry overran by two bytes every time, and a
128-character SAVEDATA_TITLE in a 128-byte slot wrote its terminator into the
next entry's data. VT_UTF8_SPE had the same missing clamp without the
off-by-one.

Both are clamped now and log when they truncate, and a negative max_size no
longer subtracts from the computed buffer size. Bytes written are unchanged for
values that do fit, which is every normal case - the terminator now comes from
the zero-fill instead of an explicit store - so this doesn't change any savedata
the emulator produces.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9
2026-08-19 19:19:06 +02:00
Henrik Rydgård 5194382b7b Fix out-of-bounds reads in PARAM.SFO parser
ReadSFO dereferenced index table entries without checking the table fit
within the buffer, and GetDataOffset had no bounds checks at all (reading
attacker-controlled offsets and strcmp'ing without a terminator guard).

- Validate the index table fits entirely within the buffer in ReadSFO.
- Add a size parameter to GetDataOffset and validate the index table,
  key/data table positions, and key string termination before use.
2026-07-31 20:54:17 +02:00
Herman Semenoff 5e2f51af8e gpu: elf: using reserve() for optimize inserts in for loop
From #21611
2026-04-28 10:53:32 +02: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 a76ce9e73e Remove bad ID check 2026-01-29 22:10:28 +01:00
Henrik Rydgård 07d47a8cc1 Make UMD_VIDEO discs with game data detect as games.
Add special case for region for wacky STEALTH + Wipeout Pure disc, see #21166
2026-01-28 23:29:44 +01:00
Henrik Rydgård f5a211884b Minor cleanups, comments
Comments and warnings
2025-12-30 20:31:06 +01:00
Henrik Rydgård 69af603df9 Fix #21064 by removing manual memory management from ParamSFO. 2025-12-15 23:35:07 +01:00
Henrik Rydgård 1c49ad7b29 Support screen rotation on iOS (unrestricted) 2025-10-22 15:13:21 +02:00
Nab 7edc3f0223 Add UNKNOWN region in place of OTHER 2025-09-06 17:18:57 +00:00
Nab 3c611355c6 Stricter check for 'H' region 2025-09-03 17:40:40 +00:00
Nab 5bfd4b390c GameRegion improvements 2025-09-03 14:17:55 +02:00
Henrik Rydgård c9acf8e80e More std::string_view 2025-08-31 20:20:59 +02:00
Henrik Rydgård 4c631e77f5 RetroAchievements: Show region when showing the info popu. Refactor region detection a little. 2025-06-01 11:34:59 +02:00
Henrik Rydgård 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Herman Semenov 192650f551 [Core/HLE/GPU/D3D11/GLES] Using for based loop C++17 and replaced on structured binding map C++17 2024-09-18 11:10:10 +02:00
Henrik Rydgård 3a047369fd Add ability to install savedata from GameFAQs-style ZIP files 2024-09-05 17:12:10 +02:00
Henrik Rydgård e01ca5b057 Logging API change (refactor) (#19324)
* Rename LogType to Log

* Explicitly use the Log:: enum when logging. Allows for autocomplete when editing.

* Mac/ARM64 buildfix

* Do the same with the hle result log macros

* Rename the log names to mixed case while at it.

* iOS buildfix

* Qt buildfix attempt, ARM32 buildfix
2024-07-14 14:42:59 +02:00
Henrik Rydgård 404600faa3 SavedataParam/ParamSFO: Minor code cleanups 2024-04-07 12:31:45 +02:00
Henrik Rydgård 77133dd82c Fix a long-standing buffer overflow in savedata encryption
BuildHash pads the buffer up to its 16-byte aligned size with zeroes,
so there needs to be space for that. Or, we should just remove that
write, but let's do the smallest change that fixes the bug for now.
2024-04-07 11:42:51 +02:00
Henrik Rydgård 2e16fd3bcc Fix fake game ID generation to work with scoped storage 2024-01-23 01:06:56 +01:00
Herman Semenov af41281761 [Core/Dialog/ELF/FileSystems/HLE/HW/Util] Added const reference for function params 2023-12-14 14:22:24 +03:00
Henrik Rydgård cf9a628a2e AndroidContentURI: Move code from the header to cpp. Some assorted cleanup, add a unit test for Download paths 2023-05-16 16:08:51 +02:00
Henrik Rydgård a43bdd8169 ReadSFO: Fix memory safety issues 2023-05-01 13:52:16 +02:00
lainon b304551747 Code readability, vec reserve() and remove excess c_str() 2022-09-30 12:31:32 +03:00
Henrik Rydgård 322a8a8b3c More checks in ParamSFO reader. Only problem left is that the strings are null terminated and can walk off the buffer. 2021-10-08 19:09:46 +02:00
Henrik Rydgård 9c017e03f9 Add some basic sanity checks to ParamSFO reader (could add more) 2021-10-07 21:08:12 +02:00
Henrik Rydgård 025bcb1673 Introduce Path, start using it all over the place.
Still lots left to convert!

Convert GetSysDirectory to return Path.

More buildfixing

Remove unnecessary Path( constructors
2021-05-13 10:39:16 +02:00
aliaspider 9a3e5879bb Global: Correct many endian types and casts. 2021-02-18 22:25:24 -08:00
Henrik Rydgård b652f62d19 SavedataParam: Be careful with const char* to string. Might help #13187 2020-08-26 22:17:42 +02:00
LunaMoo 5e0f8141d2 Corrections, some %i->%d around other code as well. 2017-05-30 13:52:29 +02:00
LunaMoo 939b26475d Fix a bunch of emu features for Homebrew by better identification. 2017-05-30 12:20:29 +02:00
Unknown W. Brackets d273deedeb Use MEMSIZE SFO param to detect 64MB homebrew.
Now, use 32MB for normal games even in PSP-2000 mode, which is how real
firmware behaves.
2015-12-23 15:16:48 -08:00
Chin 22593cddcc Use pre-increment instead of post-increment for iterators, and use auto for some iterators 2015-03-01 16:55:47 +01:00
Unknown W. Brackets 8d68c055cc Clear SFO data on game quit.
Saves the correct MENU after game exit.  Seems more sane.
2014-12-20 08:29:56 -08:00
Unknown W. Brackets ed2417731a Improve error handling when PARAM.SFO can't read. 2014-02-15 10:34:39 -08:00
Unknown W. Brackets e569bb6862 Missed one, try to fix Blackberry too. 2013-12-30 21:52:09 -08:00
Henrik Rydgård 00c32ddadb Mostly get rid of including "Globals.h" 2013-12-30 10:17:11 +01:00
Henrik Rydgard 604ad0181b Merge branch 'new-ui'. Still incomplete. Enable by setting NewUI=True in ppsspp.ini
Conflicts:
	UI/MenuScreens.cpp
2013-06-27 16:28:38 +02:00
Henrik Rydgard 645e8a7705 More NewUI, bugfix in ParamSFO where strings were created to include the trailing zero. 2013-06-09 12:41:12 +02:00
Sacha b39a572043 Buildfixes.
Fix C++11 usage.
Remove redundancy.
Fix st_*time re-usage.
2013-06-02 13:26:39 +10:00
Xele02 aa01751589 Save encryption. Load/Save encrypted/decrypted save
RE of Chnnlsv lib
Correct size bug in kirk
2013-01-29 00:11:02 +01:00
Unknown W. Brackets 140fd171ef Fix some 64-bit type conversion warnings. 2013-01-19 13:48:20 -08:00
Henrik Rydgard 883f61e3dd Savestates: Add quicksave/quickload. Add Android UI for savestates. All single slot for now. 2013-01-02 21:05:02 +01:00
Xele02 a23ca01f16 Mode 8 Correction
Modif for save encryption in Param.sfo and export save filename and
encode key in a file
2012-12-28 11:39:52 +01:00
Xele02 ab71c3d1d0 Save unencrypted PARAM.SFO 2012-12-14 20:55:57 +01:00