SA-MP Forums Archive
[CODE] String buffer overflow - help please - 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: [CODE] String buffer overflow - help please (/showthread.php?tid=332434)



[CODE] String buffer overflow - help please - squomp - 08.04.2012

//admin message/////////////////////////////////////////////////////////////
dcmd_a(playerid, params[])
{
if(pAdminLevel[playerid] >= 1 || IsPlayerAdmin(playerid))
{
new amessage[256], stringamessage[512], sendername[64];
if (sscanf(params, "s", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
GetPlayerName(playerid, sendername, sizeof(sendername));
format(stringamessage, sizeof(stringamessage), "ADMIN MESSAGE | %s: %s", sendername,amessage);
SendClientMessageToAll(blue, stringamessage);
return 1;
}
else return SendClientMessage(playerid, red, "You do not have permission to use this command");
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

no matter how big the string memory, when the message gets sent, 60% of it gets cut off and I get a message on the server saying


string buffer overflow and strings without a length are deprecated, please add a destination size


Re: [CODE] String buffer overflow - help please - Cjgogo - 08.04.2012

pawn Код:
if (sscanf(params, "s[256]", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
instead of
pawn Код:
if (sscanf(params, "s", amessage)) return SendClientMessage(playerid, 0xff0000aa, "* Usage: /a [message]");
Replace the line


Re: [CODE] String buffer overflow - help please - squomp - 08.04.2012

thank you so much