Network Remote: Check bytesAvailable >= 4 before reading length integer

This caused Clementine Remote to stop working on Android N. writeInt()
splits the 4 bytes across multiple tcp frames. Clementine would read
a wrong length and thus fail to read any protocol buffer data.
This commit is contained in:
Andreas Muttscheller 2016-09-12 12:07:28 +02:00
parent 363e88a6c4
commit e5ab3e786f
1 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,10 @@ void RemoteClient::setDownloader(bool downloader) { downloader_ = downloader; }
void RemoteClient::IncomingData() {
while (client_->bytesAvailable()) {
if (!reading_protobuf_) {
// If we have less than 4 byte, we cannot read the length. Wait for more data
if (client_->bytesAvailable() < 4) {
break;
}
// Read the length of the next message
QDataStream s(client_);
s >> expected_length_;