mirror of
https://github.com/dotnet/MQTTnet.git
synced 2026-10-18 02:13:00 +08:00
improve exceptions in case of corrupt packages close pipes after exception occoured to avoid lingering connections should fix #788
This commit is contained in:
@@ -117,6 +117,10 @@ namespace MQTTnet.AspNetCore
|
||||
var span = _buffer.Span;
|
||||
var length = BinaryPrimitives.ReadUInt16BigEndian(span.Slice(_offset));
|
||||
|
||||
if (Length < _offset + length)
|
||||
{
|
||||
throw new MqttProtocolViolationException($"Expected at least {_offset + 2 + length} bytes but there are only {Length} bytes");
|
||||
}
|
||||
var result = span.Slice(_offset + 2, length);
|
||||
_offset += 2 + length;
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user