diff options
author | Simon Rettberg | 2016-09-09 16:31:04 +0200 |
---|---|---|
committer | Simon Rettberg | 2016-09-09 16:31:04 +0200 |
commit | a39269e11e7c2d1843a4a4bf67749ae0224e4830 (patch) | |
tree | 9870de008a4ecd0fcf3902668cffb3f574e17ba4 /src/client | |
parent | Rename lock/unlock scripts to kb-lock and kb-unlock so you know it's for the ... (diff) | |
download | pvs2-a39269e11e7c2d1843a4a4bf67749ae0224e4830.tar.gz pvs2-a39269e11e7c2d1843a4a4bf67749ae0224e4830.tar.xz pvs2-a39269e11e7c2d1843a4a4bf67749ae0224e4830.zip |
Fix infinite loop when receiving incomplete headers
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/net/serverconnection.cpp | 6 | ||||
-rw-r--r-- | src/client/net/serverdiscovery.cpp | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/src/client/net/serverconnection.cpp b/src/client/net/serverconnection.cpp index c6ffd8c..54d95bc 100644 --- a/src/client/net/serverconnection.cpp +++ b/src/client/net/serverconnection.cpp @@ -379,15 +379,17 @@ void ServerConnection::sock_dataArrival() return; } - while (_socket->bytesAvailable()) + while (_socket->bytesAvailable() > 0) { bool retval; retval = _fromServer.readMessage(_socket); // let the message read data from socket - if (!retval) // error parsing msg, disconnect client! + if (retval == NM_READ_FAILED) // error parsing msg, disconnect client! { this->disconnectFromServer(); return; } + if (retval == NM_READ_INCOMPLETE) + return; if (_fromServer.readComplete()) // message is complete { this->handleMsg(); diff --git a/src/client/net/serverdiscovery.cpp b/src/client/net/serverdiscovery.cpp index 5dba327..1d1e891 100644 --- a/src/client/net/serverdiscovery.cpp +++ b/src/client/net/serverdiscovery.cpp @@ -161,7 +161,7 @@ void ServerDiscovery::onUdpReadyRead() continue; _packet.reset(); - if (!_packet.readMessage(data, (quint32)size)) + if (_packet.readMessage(data, (quint32)size) != NM_READ_OK) continue; // Valid packet, process it: |