Skip to content

Commit

Permalink
[hal] Fix potential gamedata out of bounds read (#3983)
Browse files Browse the repository at this point in the history
The size was uninitialized.  If the size is smaller than the data,
NetComm just updates the size and does not initialize the data.
  • Loading branch information
ThadHouse authored Feb 2, 2022
1 parent af5ef51 commit fcf23fc
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hal/src/main/native/athena/FRCDriverStation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit fcf23fc

Please sign in to comment.