Commit Graph
22 Commits
Author SHA1 Message Date
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 1a4a1db1b6 PBPReader: don't write the header through a const-stripping cast
header_ was declared const and value-initialized, and then the constructor read
the file into it via (u8 *)&header_. The C-style cast makes that compile, but
modifying a const object is undefined - the compiler is entitled to keep
assuming header_ still holds the zeroes it was initialized with, and fold reads
of it accordingly. It happens to work today; there's no reason to keep relying
on that.

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 3e198c53b2 More include cleanup 2024-12-18 13:57:26 +01:00
Henrik Rydgård cebb2ea96e Add missing return statement from PBPReader::GetSubFileAsString. Compiler should have rejected this.. 2024-11-04 01:15:00 +01:00
Henrik Rydgård eb5769c162 PBPReader sanity checks 2024-11-01 20:35:34 +01: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 d775bf4e4c Merge pull request #14442 from unknownbrackets/path-extension
Update path extension and PSP/GAME/ handling
2021-05-10 21:05:05 +02:00
Henrik Rydgård 9480b6672b Loaders: Rename Path() to GetPath().
Path is going to be a struct name.
2021-05-09 17:10:14 -07:00
Unknown W. Brackets 8544bd0c3e Windows: Avoid C++ files for consistency.
There's already the mingw thing, and we're avoiding these for Android
paths too.  Let's be consistent.
2021-05-09 17:00:48 -07:00
Henrik Rydgård 4f43cff5ca Move fileutil, net, image loaders, ui to Common. (#13506)
* Move and rename file_util/fd_util to Common/File/FileUtil and DirListing

Let's also move net while we're at it.

Move the ZIM/PNG loaders over to Common.

Move the UI framework into Common

iOS buildfix

* Buildfix

* Buildfixes

* Apple buildfix

* This typo again..

* UWP buildfix

* Fix build of PPSSPPQt, such as it is (it's not in good condition...)

* Guess what? Another buildfix.
2020-10-04 20:48:47 +02:00
Henrik Rydgård e2845363e9 Async I/O: Don't delay on close. Fixes #12549 (MGS:PW crash).
Also sneak in a small change in logging.
2020-01-12 18:42:28 +01:00
Henrik Rydgård eb73cc23cd Some log level changes. 2018-02-26 10:48:29 +01:00
Unknown W. Brackets 9b91713308 Right, Symbian doesn't have vector.data(). 2015-12-24 13:21:03 -08:00
Unknown W. Brackets f3df6b307f Use a FileLoader for PBPs.
Improves consistency, caching, etc.
2015-12-24 12:21:40 -08:00
Unknown W. Brackets a53f0360f3 Use a less leak prone interface for PBP reading. 2015-12-24 10:20:27 -08:00
Unknown W. Brackets 72f8f9addd Check for errors carefully in PBP loading.
Just in case.
2015-01-19 08:31:41 -08:00
Henrik Rydgård 868a3d6dd5 Load unknown.png for ELFs masquerading as PBP 2013-12-11 14:22:25 +01:00
Unknown W. Brackets 8ccd3773d9 Open files using wide functions on win32.
Fixes #3432.
2013-08-27 00:28:46 -07:00
Henrik Rydgard 0dac2b4783 Update native, minor UI stuff and cleanups 2013-08-10 23:04:23 +02:00
Unknown W. Brackets 12f4bf3664 Buildfix for Linux. 2013-04-09 00:05:05 -07:00
Unknown W. Brackets f5642f11af Buildfix. 2013-04-08 23:01:54 -07:00
Henrik Rydgard 8b6eea7df4 Load icon and bg from PBP files. 2013-04-08 21:46:54 +02:00