From d07a59e845b01afaaff84fbfe78b851af4d42a6f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sun, 14 Nov 2021 11:28:17 +0200 Subject: [PATCH] Use memorystream overload with offset --- SteamKit2/SteamKit2/Base/ClientMsg.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/SteamKit2/SteamKit2/Base/ClientMsg.cs b/SteamKit2/SteamKit2/Base/ClientMsg.cs index f6279c311..689cc556e 100644 --- a/SteamKit2/SteamKit2/Base/ClientMsg.cs +++ b/SteamKit2/SteamKit2/Base/ClientMsg.cs @@ -191,8 +191,9 @@ public ClientMsgProtobuf( IPacketMsg msg ) Header = packetMsg.Header; - using MemoryStream ms = new MemoryStream( packetMsg.GetData() ); - ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin ); + var data = packetMsg.GetData(); + var offset = (int)packetMsg.BodyOffset; + using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset ); Body = Serializer.Deserialize( ms ); @@ -353,8 +354,9 @@ public ClientMsg( IPacketMsg msg ) Header = packetMsg.Header; - using MemoryStream ms = new MemoryStream( packetMsg.GetData() ); - ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin ); + var data = packetMsg.GetData(); + var offset = (int)packetMsg.BodyOffset; + using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset ); Body.Deserialize( ms ); @@ -506,8 +508,9 @@ public Msg( IPacketMsg msg ) Header = packetMsg.Header; - using MemoryStream ms = new MemoryStream( packetMsg.GetData() ); - ms.Seek( packetMsg.BodyOffset, SeekOrigin.Begin ); + var data = packetMsg.GetData(); + var offset = (int)packetMsg.BodyOffset; + using MemoryStream ms = new MemoryStream( data, offset, data.Length - offset ); Body.Deserialize( ms );