mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal] Fix potential gamedata out of bounds read (#3983)
The size was uninitialized. If the size is smaller than the data, NetComm just updates the size and does not initialize the data.
This commit is contained in:
@@ -110,10 +110,15 @@ static int32_t HAL_GetControlWordInternal(HAL_ControlWord* controlWord) {
|
||||
|
||||
static int32_t HAL_GetMatchInfoInternal(HAL_MatchInfo* info) {
|
||||
MatchType_t matchType = MatchType_t::kMatchType_none;
|
||||
info->gameSpecificMessageSize = sizeof(info->gameSpecificMessage);
|
||||
int status = FRC_NetworkCommunication_getMatchInfo(
|
||||
info->eventName, &matchType, &info->matchNumber, &info->replayNumber,
|
||||
info->gameSpecificMessage, &info->gameSpecificMessageSize);
|
||||
|
||||
if (info->gameSpecificMessageSize > sizeof(info->gameSpecificMessage)) {
|
||||
info->gameSpecificMessageSize = 0;
|
||||
}
|
||||
|
||||
info->matchType = static_cast<HAL_MatchType>(matchType);
|
||||
|
||||
*(std::end(info->eventName) - 1) = '\0';
|
||||
|
||||
Reference in New Issue
Block a user