SA-MP Forums Archive
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: string buffer overflow (/showthread.php?tid=402257)



string buffer overflow - Chrillzen - 25.12.2012

I get this message on the console..

Code;

pawn Код:
CMD:pm(playerid, params[])
{
    new PID, message[64], pName[MAX_PLAYER_NAME], Sender[MAX_PLAYER_NAME];
    if(sscanf(params, "uz", PID, message)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /PM  [PlayerID] [Message].");
    if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, COLOR_RED, "That player is not online.");
    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, message);
        SendClientMessage(PID, COLOR_YELLOW, Str);
        format(Str, sizeof(Str), "(( PM Sent: %s(%d): %s ))", pName, PID, message);
        SendClientMessage(playerid, COLOR_YELLOW, Str);
    }
    return 1;
}



Re: string buffer overflow - thefatshizms - 25.12.2012

Try replacing the z in sscanf to s[64]
Also you don't need that else


Re: string buffer overflow - Chrillzen - 25.12.2012

Thanks, fixed.