mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-10-02 05:47:11 -05:00
Adding bounds check to getChildrenData and fixing other bugs
This commit is contained in:
@@ -204,6 +204,7 @@ class LinkWirelessMultiboot {
|
||||
if (header.isACK == 1 && header.n == 1 && header.phase == 0 &&
|
||||
header.slotState == 1) {
|
||||
hasData = true;
|
||||
// TODO: LOG CHILDRENDATA AND DEBUG WITH LONGER DISTANCES
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -224,8 +225,6 @@ class LinkWirelessMultiboot {
|
||||
LWMLOG("SendData failed!");
|
||||
return FAILURE;
|
||||
}
|
||||
if (response.dataSize == 0)
|
||||
continue;
|
||||
childrenData = linkWirelessOpenSDK->getChildrenData(response);
|
||||
|
||||
for (u32 i = 0; i < childrenData.responses[0].packetsSize; i++) {
|
||||
@@ -244,6 +243,7 @@ class LinkWirelessMultiboot {
|
||||
progress = newProgress;
|
||||
LWMLOG("-> " + std::to_string(transferredBytes * 100 / romSize));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +97,14 @@ class LinkWirelessOpenSDK {
|
||||
|
||||
ChildrenData getChildrenData(LinkRawWireless::ReceiveDataResponse response) {
|
||||
u8* buffer = (u8*)response.data;
|
||||
|
||||
u32 cursor = 0;
|
||||
ChildrenData childrenData;
|
||||
|
||||
if (response.sentBytes[1] + response.sentBytes[2] + response.sentBytes[3] +
|
||||
response.sentBytes[4] >
|
||||
response.dataSize * 4)
|
||||
return childrenData;
|
||||
|
||||
for (u32 i = 1; i < LINK_RAW_WIRELESS_MAX_PLAYERS; i++) {
|
||||
ClientResponse* clientResponse = &childrenData.responses[i - 1];
|
||||
u32 remainingBytes = response.sentBytes[i];
|
||||
|
||||
Reference in New Issue
Block a user