mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-01-26 13:47:58 +03:00
Zero-terminate Data to prevent client-side bugs.
- Fixes chat messages displaying stale memory as the client discards the data length.
This commit is contained in:
parent
b4e6433545
commit
914acc2e1b
@ -222,7 +222,7 @@ namespace Syroot.Worms.Worms2.GameServer
|
||||
+ add(PacketField.Value4, packet.Value4, sizeof(int))
|
||||
+ add(PacketField.Value10, packet.Value10, sizeof(int))
|
||||
+ add(PacketField.DataLength, packet.Data, sizeof(int))
|
||||
+ add(PacketField.Data, packet.Data, packet.Data?.Length ?? 0)
|
||||
+ add(PacketField.Data, packet.Data, (packet.Data?.Length ?? 0) + 1)
|
||||
+ add(PacketField.Error, packet.Error, sizeof(int))
|
||||
+ add(PacketField.Name, packet.Name, 20)
|
||||
+ add(PacketField.Session, packet.Session, Unsafe.SizeOf<SessionInfo>());
|
||||
@ -244,8 +244,10 @@ namespace Syroot.Worms.Worms2.GameServer
|
||||
if (packet.Value10 != null) writeInt(ref span, packet.Value10.Value);
|
||||
if (packet.Data != null)
|
||||
{
|
||||
writeInt(ref span, packet.Data.Length);
|
||||
writeInt(ref span, packet.Data.Length + 1);
|
||||
span = span.Slice(Encodings.Windows1252.GetBytes(packet.Data, span));
|
||||
span[0] = 0;
|
||||
span = span.Slice(1);
|
||||
}
|
||||
if (packet.Error != null) writeInt(ref span, packet.Error.Value);
|
||||
if (packet.Name != null)
|
||||
|
@ -8,7 +8,7 @@
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>Worms 2 Game Server</Description>
|
||||
<Version>1.1.0</Version>
|
||||
<Version>1.1.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- References -->
|
||||
|
Loading…
x
Reference in New Issue
Block a user