Explorar el Código

Merge pull request #937 from chkr1011/fix-writeasync-nre

Added checks for null references in the MqttTcpChannel.
release/3.x.x
Christian hace 4 años
committed by GitHub
padre
commit
4fa275bf2b
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 4AEE18F83AFDEB23
Se han modificado 2 ficheros con 17 adiciones y 2 borrados
  1. +1
    -0
      Build/MQTTnet.nuspec
  2. +16
    -2
      Source/MQTTnet/Implementations/MqttTcpChannel.cs

+ 1
- 0
Build/MQTTnet.nuspec Ver fichero

@@ -17,6 +17,7 @@
* [Server] Adjusted some namespaces (BREAKING CHANGE!)
* [Server] Added state checks (throw if not started etc.) for most server APIs.
* [Server] Exposed real X509Certificate2 (instead byte array) to TLS options (thanks to @borigas).
* [Core] Fixed a null reference exception in the MqttTcpChannel with WriteAsync and ReadAsync.
</releaseNotes>
<copyright>Copyright Christian Kratky 2016-2020</copyright>
<tags>MQTT Message Queue Telemetry Transport MQTTClient MQTTServer Server MQTTBroker Broker NETStandard IoT InternetOfThings Messaging Hardware Arduino Sensor Actuator M2M ESP Smart Home Cities Automation Xamarin Blazor</tags>


+ 16
- 2
Source/MQTTnet/Implementations/MqttTcpChannel.cs Ver fichero

@@ -127,7 +127,14 @@ namespace MQTTnet.Implementations
// Workaround for: https://github.com/dotnet/corefx/issues/24430
using (cancellationToken.Register(Dispose))
{
return await _stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
var stream = _stream;

if (stream == null)
{
throw new ObjectDisposedException(nameof(stream));
}

return await stream.ReadAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
}
}
catch (ObjectDisposedException)
@@ -157,7 +164,14 @@ namespace MQTTnet.Implementations
// Workaround for: https://github.com/dotnet/corefx/issues/24430
using (cancellationToken.Register(Dispose))
{
await _stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
var stream = _stream;

if (stream == null)
{
throw new ObjectDisposedException(nameof(stream));
}

await stream.WriteAsync(buffer, offset, count, cancellationToken).ConfigureAwait(false);
}
}
catch (ObjectDisposedException)


Cargando…
Cancelar
Guardar