Repository navigation
Fix MD5Sum hashing hostfs::File pointers instead of file contents (GGPO verification) - #2513
Merged
Merged
Conversation
Since the switch to hostfs::File (flyinghead#2299), MD5Sum::add(hostfs::File *) resolved to the generic add(const T&) template, which hashes the pointer value. The resulting digests depend on the heap address, so they differ between peers and between runs. This breaks GGPO peer verification when a .state.net savestate is used (stateMD5), and with CDI, GDI and CUE images (gameMD5). Add an MD5Sum::add(hostfs::File *) overload that hashes the whole file content, like the std::FILE overload, and reject pointer types in the template with a static_assert so this cannot happen again silently.
Owner
|
Is this PR still a Draft or can it be merged? |
Press5elect
pushed a commit
to Press5elect/PSFlycast
that referenced
this pull request
Oct 7, 2026
…ast's open pull requests, release candidates in the updater, no Screenshot control - Netplay: the checksum of a save state or of a CDI, GDI or CUE image is the file's, not its pointer's (flyinghead#2513). - sh4: the FPSCR cause field is cleared when the guest writes FPSCR (flyinghead#2531). - CHD: the track metadata's text fields are held to their buffers (flyinghead#2384). - Input: absolute mouse motion rebased after relative input (flyinghead#2528); axis detection for triggers that report as buttons (flyinghead#2213). - Checks of an ISO9660 directory record, RZIP chunk sizes, DNS answers, GGPO input packets and card events, and a Naomi LST's ranges (flyinghead#2414, flyinghead#2415, flyinghead#2416, flyinghead#2519, flyinghead#2520, flyinghead#2521). - The updater ranks v1.1.0-rc1 under v1.1.0, and a release's build is not offered candidates. - The quick menu's Screenshot row and control are gone: the console's Create button takes screenshots. - Built with PS5_Vulkan 5b5e4fc, the payload SDK fork at b5efad5 and libsmb2 7e4ff97. Co-Authored-By: Claude Opus 5.5 <[email protected]>
flyinghead
marked this pull request as ready for review
October 12, 2026 07:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since the file I/O indirection (#2299), several call sites pass a
hostfs::File *toMD5Sum::add(). There is no overload for that type, so the call resolves to the genericadd(const T&)template, which hashes the pointer value instead of the file contents:nullDC.cppdc_loadstate():settings.network.md5.savestate(GGPOstateMD5when a.state.netis used)imgread/cdi.cpp,imgread/gdi.cpp,imgread/cue.cpp: disc digest (GGPOgameMD5)The digests then depend on the heap address, so they differ between peers (and between runs on the same machine). As a result, GGPO netplay always fails with "Verification mismatch" / "Peer verification failed" when using a
.state.netsavestate, or when playing CDI, GDI or CUE images. CHD images are not affected (their digest comes from the CHD header).Captured
sync_requestverification data, v2.7 flatpak, same.state.neton both peers:984ac73c…ad9318c4…(changes every run)984ac73c…43b054c4…(changes every run)984ac73c…628deb6c…Fix
MD5Sum::add(hostfs::File *), which hashes the whole file content, with the same semantics as the existingstd::FILE *overload (rewinds first).static_assertin the generic template that rejects pointer types, so this cannot silently happen again.Tests
tests/src/util/Md5SumTest.cpp:MD5Sumof ahostfs::Fileequals the MD5 of its content, independently of the current position, and matches thestd::FILEoverload.test_cues/d/cs.cuereturned byOpenDisc()equals the MD5 of its track data.The three tests fail without the fix and pass with it. The rest of the suite is unchanged.
Also verified end-to-end: GGPO netplay of a GD-ROM game (CHD) with a shared
.state.netbetween x86_64 ↔ x86_64 and x86_64 ↔ aarch64 Linux handhelds (flatpak v2.7 + this patch, both architectures), which always failed verification before. Also re-checked after rebooting both devices.