mirror of
https://github.com/libretro/Mesen.git
synced 2024-11-27 11:00:50 +00:00
NetPlay: Fixed crash that occurred when bytes were > 127. Signed chars ended up becoming huge unsigned numbers, triggering the maximum message length and closing the connection.
This commit is contained in:
parent
c772d4d0d5
commit
a681b4992c
@ -15,7 +15,7 @@ GameConnection::GameConnection(shared_ptr<Socket> socket, shared_ptr<ClientConne
|
||||
|
||||
void GameConnection::ReadSocket()
|
||||
{
|
||||
int bytesReceived = _socket->Recv(_readBuffer + _readPosition, 0x40000 - _readPosition, 0);
|
||||
int bytesReceived = _socket->Recv((char*)_readBuffer + _readPosition, 0x40000 - _readPosition, 0);
|
||||
if(bytesReceived > 0) {
|
||||
_readPosition += bytesReceived;
|
||||
}
|
||||
@ -25,7 +25,7 @@ bool GameConnection::ExtractMessage(void *buffer, uint32_t &messageLength)
|
||||
{
|
||||
messageLength = _readBuffer[0] | (_readBuffer[1] << 8) | (_readBuffer[2] << 16) | (_readBuffer[3] << 24);
|
||||
|
||||
if(messageLength > 100000) {
|
||||
if(messageLength > 1000000) {
|
||||
std::cout << "Invalid data received, closing connection" << std::endl;
|
||||
_socket->Close();
|
||||
return false;
|
||||
|
@ -11,8 +11,8 @@ class GameConnection
|
||||
protected:
|
||||
shared_ptr<Socket> _socket;
|
||||
shared_ptr<ClientConnectionData> _connectionData;
|
||||
char _readBuffer[0x40000];
|
||||
char _messageBuffer[0x40000];
|
||||
uint8_t _readBuffer[0x40000];
|
||||
uint8_t _messageBuffer[0x40000];
|
||||
int _readPosition = 0;
|
||||
SimpleLock _socketLock;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user