citizenfx / fivem

The source code for the Cfx.re modification frameworks, such as FiveM, RedM and LibertyM, as well as FXServer.
https://cfx.re/
3.4k stars 1.99k forks source link

[MonoV2] Receiving events above 256 bytes leads to ArgumentException in MsgPackDeserializer #2613

Open Keyinator opened 5 days ago

Keyinator commented 5 days ago

What happened?

Receiving an Event with a string grater than 256 bytes leads to System.ArgumentException within MsgPackDeserializer

Full error:

[  18754843] [b2699_GTAProce]             MainThrd/ System.ArgumentException: MsgPackDeserializer tried to retrieve 321 bytes while only 256 bytes remain
[  18754843] [b2699_GTAProce]             MainThrd/   at CitizenFX.MsgPack.MsgPackDeserializer.AdvancePointer (System.UInt32 amount) [0x0005d] in C:\gl\builds\cfx-fivem\master\fivem\vendor\msgpack-cs\MsgPack\MsgPackDeserializer.cs:394 
[  18754843] [b2699_GTAProce]             MainThrd/   at CitizenFX.MsgPack.MsgPackDeserializer.DeserializeAsString () [0x001de] in C:\gl\builds\cfx-fivem\master\fivem\vendor\msgpack-cs\MsgPack\MsgPackDeserializerConvert.cs:559 
[  18754843] [b2699_GTAProce]             MainThrd/   at (wrapper dynamic-method) System.Object:GCClient.ModusControl.ModusController.JoinMode (object,CitizenFX.Core.Remote,CitizenFX.MsgPack.MsgPackDeserializer&)
[  18754843] [b2699_GTAProce]             MainThrd/   at CitizenFX.Core.EventsManager.IncomingEvent (System.String eventName, System.String sourceString, CitizenFX.Core.Binding origin, System.Byte* argsSerialized, System.Int32 serializedSize) [0x00050] in C:\gl\builds\cfx-fivem\master\fivem\code\client\clrcore-v2\Interop\EventsManager.cs:34 

Expected result

string deserialized without issue

Reproduction steps

public class ReproScriptServer : BaseScript {
    [EventHandler("playerJoining")]
    private void OnPlayerJoining([Source] Player player, string oldId) {
        player.TriggerEvent("SendString", new string('A', 256) + "B");
    }
}

public class ReproScriptClient : BaseScript {
    [EventHandler("SendString")]
    public void JoinMode(string stringValue) {
        Debug.WriteLine($"Succesfully received: {stringValue}");
    }
}

Importancy

Crash

Area(s)

FiveM, Natives, ScRT: C#

Specific version(s)

Version: FXServer-master v1.0.0.8780 linux with OneSync enabled

Additional information

No response