what the problem with this in sscanf? -
drichie - 07.07.2013
it always appear string buffer oveflow in the new name and loc
pawn Код:
if(!strcmp(option, "name", true, 4))
{
new name[32];
if(sscanf(params, "is[10]s[32]",i,option,name)) return SCM(playerid,-1, "[Usage]: /credit [robid] name [name]");
if(PickInfo[i][pPick] == 0) return SendClientMessage(playerid,-1, "Invalid door id.");
format(string, sizeof(string), " You have set rob ID %d's name to %s",i,name);
SCM(playerid,COLOR_LIGHTBLUE, string);
PickInfo[i][pRname] = name;
}
if(!strcmp(option, "location", true, 8))
{
new loc[32];
if(sscanf(params, "is[10]s[32]",i,option,loc)) return SCM(playerid,-1, "[Usage]: /credit [robid] location [loc]");
if(PickInfo[i][pPick] == 0) return SendClientMessage(playerid,-1, "Invalid door id.");
format(string, sizeof(string), " You have set rob ID %d's location to %s",i,loc);
SCM(playerid,COLOR_LIGHTBLUE, string);
PickInfo[i][pLoc] = loc;
}
Re: what the problem with this in sscanf? -
SwisherSweet - 07.07.2013
Explain your problem with detail
Re: what the problem with this in sscanf? -
drichie - 07.07.2013
in that code i always get string buffer overflow example i wrote a this command /credit 0 name drich or /credit 0 location drich then the string overflow will appear but when i type /credit 0 name dric or /credit 0 location dric it does not appear and i think the problem is in this line
new name[32];
if(sscanf(params, "is[10]s[32]",i,option,name))
and this line
new loc[32];
if(sscanf(params, "is[10]s[32]",i,option,loc))
Re: what the problem with this in sscanf? -
Konstantinos - 07.07.2013
Have you read the thread of sscanf? Goto
https://sampforum.blast.hk/showthread.php?tid=120356 and read at the bottom of the first post about "Errors/Warnings" - "sscanf warning: String buffer overflow."
Re: what the problem with this in sscanf? -
drichie - 08.07.2013
yeah i read that already please see my problem before anthing else i do the format that said in that topic if you do know what might be the problem is you can pin point it
Re: what the problem with this in sscanf? -
drichie - 08.07.2013
thx mr ****** but am i doing this correct? the first string will be the option that save up to 10 cells which only involve between name and location only then the second string is for the name and loc thats why i made new name and loc variable that will save 32 cells for the name and location you will input
pawn Код:
new i,option[10],string[200];
if(sscanf(params, "is[10]",i,option))
{
SCM(playerid, -1, "[Usage]: /credit [robid] [option]");
SCM(playerid, -1, "OPTIONS: name | location | robcash");
return 1;
}
if(!strcmp(option, "name", true, 4))
{
new name[32];
if(sscanf(params, "is[10]s[32]",i,option,name)) return SCM(playerid,-1, "[Usage]: /credit [robid] name [name]");
if(PickInfo[i][pPick] == 0) return SendClientMessage(playerid,-1, "Invalid door id.");
format(string, sizeof(string), " You have set rob ID %d's name to %s",i,name);
SCM(playerid,COLOR_LIGHTBLUE, string);
PickInfo[i][pRname] = name;
}
if(!strcmp(option, "location", true, 8))
{
new loc[32];
if(sscanf(params, "is[10]s[32]",i,option,loc)) return SCM(playerid,-1, "[Usage]: /credit [robid] location [loc]");
if(PickInfo[i][pPick] == 0) return SendClientMessage(playerid,-1, "Invalid door id.");
format(string, sizeof(string), " You have set rob ID %d's location to %s",i,loc);
SCM(playerid,COLOR_LIGHTBLUE, string);
PickInfo[i][pLoc] = loc;
}
Re: what the problem with this in sscanf? -
drichie - 08.07.2013
how about using two string specifier? sorry just a noob
Re: what the problem with this in sscanf? -
Konstantinos - 08.07.2013
You have an array of 10 for "option". If someone types more than 9 characters, then it will print the warning.