Skip to content

Commit aef654c

Browse files
committed
Fix potential out of bounds access
1 parent d2dfc85 commit aef654c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Source/Native/enet.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,9 +2761,9 @@ static int enet_protocol_check_outgoing_commands(ENetHost* host, ENetPeer* peer)
27612761
ENetBuffer* buffer = &host->buffers[host->bufferCount];
27622762
ENetOutgoingCommand* outgoingCommand;
27632763
ENetListIterator currentCommand;
2764-
ENetChannel* channel;
2765-
uint16_t reliableWindow;
2766-
size_t commandSize;
2764+
ENetChannel* channel = NULL;
2765+
uint16_t reliableWindow = 0;
2766+
size_t commandSize = 0;
27672767
int windowExceeded = 0, windowWrap = 0, canPing = 1;
27682768
currentCommand = enet_list_begin(&peer->outgoingCommands);
27692769

@@ -3150,15 +3150,16 @@ int enet_peer_throttle(ENetPeer* peer, uint32_t rtt) {
31503150
}
31513151

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

31573157
if (peer->state != ENET_PEER_STATE_CONNECTED || channelID >= peer->channelCount || packet->dataLength > peer->host->maximumPacketSize) {
31583158
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.");
31593159
return -1;
31603160
}
3161-
3161+
3162+
channel = &peer->channels[channelID];
31623163
fragmentLength = peer->mtu - sizeof(ENetProtocolHeader) - sizeof(ENetProtocolSendFragment) - sizeof(ENetProtocolAcknowledge);
31633164

31643165
if (peer->host->checksumCallback != NULL)

0 commit comments

Comments
 (0)