SA-MP Forums Archive
sscanf: String buffer overflow - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf: String buffer overflow (/showthread.php?tid=348159)



sscanf: String buffer overflow - Kurtis96z - 04.06.2012

Well my command is not working right I am sure I am missing something really basic but I just cant see what.

Quote:

{
new PID, reason[35], pName[MAX_PLAYER_NAME], Sender[MAX_PLAYER_NAME];
if(sscanf(params, "us", PID, reason)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /PM [playerid/partofname] [message]");
if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000FF, "That user is not connected!");
else
{
new Str[256];
GetPlayerName(PID, pName, sizeof(pName));
GetPlayerName(playerid, Sender, sizeof(Sender));
format(Str, sizeof(Str), "(( PM From: %s(%d): %s ))", Sender, playerid, reason);
SendClientMessage(PID, 0xF6C861AA, Str);
format(Str, sizeof(Str), "(( PM Sent To: %s(%d): %s ))", pName, PID, reason);
SendClientMessage(playerid, 0xF6C861AA, Str);
}
return 1;
}

What is wrong with this?
It says in the server log:

[07:59:41] sscanf warning: Strings without a length are deprecated, please add a destination size.
[07:59:41] sscanf warning: String buffer overflow.


Re: sscanf: String buffer overflow - Kurtis96z - 04.06.2012

How do I make it know that?


Re: sscanf: String buffer overflow - Kurtis96z - 04.06.2012

Thanks, problem solved.