Просмотр исходного кода

Fix infinite loop that can occur when the client closes the connection before sending the complete packet body.

release/3.x.x
kpreisser 7 лет назад
Родитель
Сommit
d020e809a1
1 измененных файлов: 6 добавлений и 0 удалений
  1. +6
    -0
      Frameworks/MQTTnet.NetStandard/Adapter/MqttChannelAdapter.cs

+ 6
- 0
Frameworks/MQTTnet.NetStandard/Adapter/MqttChannelAdapter.cs Просмотреть файл

@@ -137,6 +137,12 @@ namespace MQTTnet.Adapter
do
{
var readBytesCount = await stream.ReadAsync(body, offset, body.Length - offset, cancellationToken).ConfigureAwait(false);
// Check if the client closed the connection before sending the full body.
if (readBytesCount == 0)
{
throw new MqttCommunicationException("Connection closed while reading remaining packet body.");
}

offset += readBytesCount;
} while (offset < header.BodyLength);


Загрузка…
Отмена
Сохранить