Skip to content
Permalink
Browse files

IOS/USB: Verify that isochronous req buffer size is consistent

To catch possible bugs.
  • Loading branch information...
leoetlino committed May 2, 2019
1 parent a6da38d commit 4c6ef812913943673ab61295cf9e9c139d9ae366
Showing with 9 additions and 1 deletion.
  1. +9 −1 Source/Core/Core/IOS/USB/USBV5.cpp
@@ -8,6 +8,7 @@
#include <cstddef>
#include <cstring>

#include "Common/Assert.h"
#include "Common/ChunkFile.h"
#include "Common/Logging/Log.h"
#include "Common/Swap.h"
@@ -48,9 +49,16 @@ V5IsoMessage::V5IsoMessage(Kernel& ios, const IOCtlVRequest& ioctlv)
num_packets = Memory::Read_U8(ioctlv.in_vectors[0].address + 16);
endpoint = Memory::Read_U8(ioctlv.in_vectors[0].address + 17);
packet_sizes_addr = ioctlv.GetVector(1)->address;
u32 total_packet_size = 0;
for (size_t i = 0; i < num_packets; ++i)
packet_sizes.push_back(Memory::Read_U16(static_cast<u32>(packet_sizes_addr + i * sizeof(u16))));
{
const u32 packet_size = Memory::Read_U16(static_cast<u32>(packet_sizes_addr + i * sizeof(u16)));
packet_sizes.push_back(packet_size);
total_packet_size += packet_size;
}
length = ioctlv.GetVector(2)->size;
ASSERT_MSG(IOS_USB, length == total_packet_size, "Wrong buffer size (0x%x != 0x%x)", length,
total_packet_size);
}
} // namespace USB

0 comments on commit 4c6ef81

Please sign in to comment.
You can’t perform that action at this time.