Pass correct length to DecodeImpl

This commit is contained in:
Haselnussbomber 2025-09-20 01:54:47 +02:00
parent bf4fc7864f
commit 327ebf3bb3
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
2 changed files with 3 additions and 5 deletions

View file

@ -208,7 +208,7 @@ public abstract partial class Payload
}
payload ??= new RawPayload((byte)chunkType);
payload.DecodeImpl(reader, reader.BaseStream.Position + chunkLen - 1);
payload.DecodeImpl(reader, reader.BaseStream.Position + chunkLen);
// read through the rest of the packet
var readBytes = (uint)(reader.BaseStream.Position - packetStart);

View file

@ -95,14 +95,12 @@ public class RawPayload : Payload
/// <inheritdoc/>
protected override byte[] EncodeImpl()
{
var chunkLen = this.data.Length + 1;
var bytes = new List<byte>()
{
START_BYTE,
this.chunkType,
(byte)chunkLen,
};
bytes.AddRange(MakeInteger((uint)this.data.Length)); // chunkLen
bytes.AddRange(this.data);
bytes.Add(END_BYTE);
@ -113,6 +111,6 @@ public class RawPayload : Payload
/// <inheritdoc/>
protected override void DecodeImpl(BinaryReader reader, long endOfStream)
{
this.data = reader.ReadBytes((int)(endOfStream - reader.BaseStream.Position + 1));
this.data = reader.ReadBytes((int)(endOfStream - reader.BaseStream.Position));
}
}