Skip to content

Commit

Permalink
Fix potential out of bounds access
Browse files Browse the repository at this point in the history
  • Loading branch information
SoftwareGuy committed Apr 29, 2021
1 parent d2dfc85 commit aef654c
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions Source/Native/enet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2761,9 +2761,9 @@ static int enet_protocol_check_outgoing_commands(ENetHost* host, ENetPeer* peer)
ENetBuffer* buffer = &host->buffers[host->bufferCount];
ENetOutgoingCommand* outgoingCommand;
ENetListIterator currentCommand;
ENetChannel* channel;
uint16_t reliableWindow;
size_t commandSize;
ENetChannel* channel = NULL;
uint16_t reliableWindow = 0;
size_t commandSize = 0;
int windowExceeded = 0, windowWrap = 0, canPing = 1;
currentCommand = enet_list_begin(&peer->outgoingCommands);

Expand Down Expand Up @@ -3150,15 +3150,16 @@ int enet_peer_throttle(ENetPeer* peer, uint32_t rtt) {
}

int enet_peer_send(ENetPeer* peer, uint8_t channelID, ENetPacket* packet) {
ENetChannel* channel = &peer->channels[channelID];
ENetChannel* channel;
ENetProtocol command;
size_t fragmentLength;

if (peer->state != ENET_PEER_STATE_CONNECTED || channelID >= peer->channelCount || packet->dataLength > peer->host->maximumPacketSize) {
ENET_LOG_ERROR("Failed sending data. Peer is not connected, the channel is above the maximum channels supported or the payload length is too large.");
return -1;
}


channel = &peer->channels[channelID];
fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment) - sizeof(ENetProtocolAcknowledge);

if (peer->host->checksumCallback != NULL)
Expand Down

0 comments on commit aef654c

Please sign in to comment.