katursis / Pawn.RakNet

🛡 Plugin for SA:MP 0.3.7 server that allows you to capture and analyze RakNet traffic

Home Page:https://github.com/katursis/Pawn.RakNet/wiki

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

crash server

plakapenka opened this issue · comments

incoming code

public OnIncomingPacket(playerid, packetid, BitStream:bs) 
{

	if(packetid == 251)
	{
		new header, rpcid;

		BS_ReadUint8(bs, header);
		BS_ReadUint8(bs, rpcid);

		if(rpcid == 41)
		{
			new _strlen, _authKey[65];
			BS_ReadUint32(bs, _strlen);
			BS_ReadString(bs, _authKey, _strlen);
		}
	}
}

send:

BitStream bs; 
            bs.Write((BYTE)251);
            bs.Write((uint8)41);
            bs.Write((uint32)64); 
            bs.Write((std::string)"asfrtrefdasf"); 
            SF->getRakNet()->SendPacket(&bs); 

crash:

[16:23:16] [debug] Server crashed while executing brilliant.amx
[16:23:16] [debug] AMX backtrace:
[16:23:16] [debug] #0 native BS_ReadValue () in pawnraknet.DLL
[16:23:16] [debug] #1 00034c14 in public OnIncomingPacket (playerid=0, packetid=251, BitStream:bs=1703132) at 

line crash

BS_ReadString(bs, _authKey, _strlen);

If you replace BS_ReadUint32(bs, _strlen); with BS_ReadUint16(bs, _strlen); or 8 then it seems to work. But I would like to know the reason.
Maybe I'm an idiot