Sscanf's "frrezing" strings
#1

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

how can i fix it?
Reply
#2

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.
Reply
#3

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

#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 ?
Reply
#5

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.
Reply
#6

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

pls somebody send me an example line
Reply
#7

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?
Reply
#8

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?
Reply
#9

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.
Reply
#10

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;
}
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)