As XPP_DEVICE_TYPE contains Reserved[3] it has elements numbered [0-2], so ensure we don't access memory outside the array bounds

This commit is contained in:
Echelon9 2012-10-08 01:13:30 +11:00
parent 929a108885
commit cb671b2a27
1 changed files with 4 additions and 4 deletions

View File

@ -485,10 +485,10 @@ DWORD WINAPI XTL::EmuXGetDevices
DWORD ret = 0; DWORD ret = 0;
if(DeviceType->Reserved[0] == 0 && DeviceType->Reserved[1] == 0 && DeviceType->Reserved[2] == 0 && DeviceType->Reserved[3] == 0) if(DeviceType->Reserved[0] == 0 && DeviceType->Reserved[1] == 0 && DeviceType->Reserved[2] == 0)
ret = (1 << 0); // Return 1 Controller ret = (1 << 0); // Return 1 Controller
else else
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2], DeviceType->Reserved[3]); EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
EmuSwapFS(); // XBox FS EmuSwapFS(); // XBox FS
@ -521,7 +521,7 @@ BOOL WINAPI XTL::EmuXGetDeviceChanges
// Return 1 Controller Inserted initially, then no changes forever // Return 1 Controller Inserted initially, then no changes forever
if(bFirst) if(bFirst)
{ {
if(DeviceType->Reserved[0] == 0 && DeviceType->Reserved[1] == 0 && DeviceType->Reserved[2] == 0 && DeviceType->Reserved[3] == 0) if(DeviceType->Reserved[0] == 0 && DeviceType->Reserved[1] == 0 && DeviceType->Reserved[2] == 0)
{ {
*pdwInsertions = (1<<0); *pdwInsertions = (1<<0);
*pdwRemovals = 0; *pdwRemovals = 0;
@ -531,7 +531,7 @@ BOOL WINAPI XTL::EmuXGetDeviceChanges
else else
{ {
// TODO: What if it's not a controller? // TODO: What if it's not a controller?
EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2], DeviceType->Reserved[3]); EmuWarning("Unknown DeviceType (0x%.08X, 0x%.08X, 0x%.08X)\n", DeviceType->Reserved[0], DeviceType->Reserved[1], DeviceType->Reserved[2]);
} }
} }
else else