Commit Graph
13 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 eb5769c162 PBPReader sanity checks 2024-11-01 20:35:34 +01:00
Henrik Rydgård 534896d2ab ControlMapper: Allow overriding PSP button event handling through a callback. 2023-03-28 00:23:18 +02:00
Unknown W. Brackets 2479d52202 Global: Reduce includes of common headers.
In many places, string, map, or Common.h were included but not needed.
2022-01-30 16:35:33 -08:00
Henrik Rydgård 6a1fa728d8 Remove Globals.h 2017-08-31 17:15:22 +02: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 a6436d04f5 Support PIC0 in PBP files. 2014-06-21 18:29:54 -07:00
Henrik Rydgård 868a3d6dd5 Load unknown.png for ELFs masquerading as PBP 2013-12-11 14:22:25 +01:00
Unknown W. Brackets 0b5bdeb1d3 Fix some compile failures under big endian. 2013-07-28 21:04:17 -07:00
Unknown W. Brackets ae5851a393 Use _le typedefs in elf reading. 2013-07-25 08:04:35 -07:00
Henrik Rydgard 8b6eea7df4 Load icon and bg from PBP files. 2013-04-08 21:46:54 +02:00