SA-MP Forums Archive
Sscanf's "frrezing" strings - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sscanf's "frrezing" strings (/showthread.php?tid=201888)



Sscanf's "frrezing" strings - LZLo - 22.12.2010

sscanf warning: Strings without a length are deprecated, please add a destination size.
sscanf warning: String buffer overflow.

how can i fix it?


Re: Sscanf's "frrezing" strings - [MWR]Blood - 22.12.2010

Show us your code?
I just can't understand people which just post their warnings\errors without posting their code and expecting to get help, lol.


Re: Sscanf's "frrezing" strings - LZLo - 22.12.2010

do you want to read 23.918 lines?
(freeroam server )


Re: Sscanf's "frrezing" strings - LZLo - 22.12.2010

#define dcmd(%1,%2,%3) if ((strcmp((%3)[1], #%1, true, (%2)) == 0) && ((((%3)[(%2) + 1] == 0) && (dcmd_%1(playerid, "")))||(((%3)[(%2) + 1] == 32) && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1

it's ?


Re: Sscanf's "frrezing" strings - Scenario - 22.12.2010

You aren't assigning string lengths to your string variables and you are also loading too much data for one sscanf line; you need to increase the size.


Re: Sscanf's "frrezing" strings - LZLo - 22.12.2010

the "sscanf warning: String buffer overflow." is solved

pls somebody send me an example line


Re: Sscanf's "frrezing" strings - LZLo - 22.12.2010

Quote:

if (!sscanf(buffer_str, BUFFER_READ_FORMAT , BUFFER_PARAMS(point)))

else if (!sscanf(buffer_str, OLD_BUF_READ_FORMAT, OLD_BUF_PARAMS(point)))

if (sscanf(params, "ds["#MAX_POINT_NAME_LENGHT"]", para, name))

and what's this or where must i take it?


Re: Sscanf's "frrezing" strings - LZLo - 22.12.2010

Quote:

dcmd_pm(playerid, params[])
{
new id, msg[85];
if(sscanf(params, "us", id, msg)) return SendClientMessage(playerid, COLOR_ORANGE, "Hazsnбlat: /Pm [Nйv/ID] [ьzenet]");
if(isnull(msg) || strlen(msg) > 90) return SendClientMessage(playerid, COLOR_RED, "Hibбs PM hosszъsбg! (Min 1->Max 90 karakter)");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Rossz ID / Nйv!");
if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "Nem tudsz PM-t kьldeni magadnak!");
{
SendMSG(playerid, COLOR_YELLOW, ">> %s (%d): %s", pNick(id), id, msg);
SendMSG(id, COLOR_YELLOW, "*** %s (%d): %s", pNick(playerid), playerid, msg);
}
return 1;
}

it is the problem?


Re: Sscanf's "frrezing" strings - Kyosaur - 22.12.2010

Dont triple post, wait for someone to answer.


The first warning is basically straight forward. You are using "s" which is deprecated. You need to add a size to the strings, so ...do that. An example would be: "s[127]" where 127 is the size (size is dependent to your string size, dont just use "127" all the time).

The sscanf buffer overflow warning means that your string length is equal to, and or greater than the actual variable's size. You're string specifier size should always be one less then the actual size, otherwise when the terminating NULL character is appended, it will be out of boundaries and could even corrupt something.


Re: Sscanf's "frrezing" strings - armyoftwo - 22.12.2010

pawn Код:
dcmd_pm(playerid, params[])
{
new id, msg[85];
if(sscanf(params, "us[85]", id, msg)) return SendClientMessage(playerid, COLOR_ORANGE, "Hazsnбlat: /Pm [Nйv/ID] [ьzenet]");
if(isnull(msg) || strlen(msg) > 90) return SendClientMessage(playerid, COLOR_RED, "Hibбs PM hosszъsбg! (Min 1->Max 90 karakter)");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "Rossz ID / Nйv!");
if(id == playerid) return SendClientMessage(playerid, COLOR_RED, "Nem tudsz PM-t kьldeni magadnak!");
{
SendMSG(playerid, COLOR_YELLOW, ">> %s (%d): %s", pNick(id), id, msg);
SendMSG(id, COLOR_YELLOW, "*** %s (%d): %s", pNick(playerid), playerid, msg);
}
return 1;
}