dolphin/Source/UnitTests
Pokechu22 a3951dc2d7 Fix out of bounds accesses for invalid vertex component formats
On all platforms, this would result in out of bounds accesses when getting the component sizes (which uses stuff from VertexLoader_Position.h/VertexLoader_TextCoord.h/VertexLoader_Normal.h). On platforms other than x64 and ARM64, this would also be out of bounds accesses when getting function pointers for the non-JIT vertex loader (in VertexLoader_Position.cpp etc.). Usually both of these would get data from other entries in the same multi-dimensional array, but the last few entries would be truly out of bounds. This does mean that an out of bounds function pointer can be called on platforms that don't have a JIT vertex loader, but it is limited to invalid component formats with values 5/6/7 due to the size of the bitfield the formats come from, so it seems unlikely that this could be exploited in practice.

This issue affects a few games; Def Jam: Fight for New York (https://bugs.dolphin-emu.org/issues/12719) and Fifa Street are known to be affected.

I have not done any hardware testing for this PR specifically, though I *think* I previously determined that at least a value of 5 behaves the same as float (4). That's what I implemented in any case. I did previously determine that both Def Jam: Fight for New York and Fifa Street use an invalid normal format, but don't actually have lighting enabled when that normal vector is used, so it doesn't change rendering in practice.

The color component format also has two invalid values, but VertexLoader_Color.h/.cpp do check for those invalid ones and return a default value instead of doing an out of bounds access.
2024-04-04 12:50:34 -07:00
..
Common Add simple unit tests for SettingsHandler 2024-03-01 20:52:45 -08:00
Core DivUtils: Add unsigned division magic function 2024-03-23 20:13:15 +01:00
VideoCommon Fix out of bounds accesses for invalid vertex component formats 2024-04-04 12:50:34 -07:00
CMakeLists.txt CMake: Set --output-on-failure flag for unittests target. 2023-05-14 04:52:50 +02:00
StubHost.cpp DolphinQt: A Ubiquitous Signal For When Symbols Change 2024-03-28 09:57:22 -07:00
UnitTests.vcxproj Add simple unit tests for SettingsHandler 2024-03-01 20:52:45 -08:00
UnitTests.vcxproj.user msbuild: use default Project attrs 2022-04-27 15:26:43 -07:00
UnitTestsMain.cpp Core: Assert that only the Host thread may call PauseAndLock(). 2023-06-02 18:51:43 +02:00