Bläddra i källkod

Merge pull request #163 from kpreisser/fixInfiniteLoop

Fix infinite loop when the client closes the connection
release/3.x.x
Christian 6 år sedan
committed by GitHub
förälder
incheckning
64c997a4a2
Ingen känd nyckel hittad för denna signaturen i databasen GPG-nyckel ID: 4AEE18F83AFDEB23
1 ändrade filer med 6 tillägg och 0 borttagningar
  1. +6
    -0
      Frameworks/MQTTnet.NetStandard/Adapter/MqttChannelAdapter.cs

+ 6
- 0
Frameworks/MQTTnet.NetStandard/Adapter/MqttChannelAdapter.cs Visa fil

@@ -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);


Laddar…
Avbryt
Spara