String Buffer Overflow -
Antonio [G-RP] - 08.02.2011
I've looked over the code, it matches the database.
I still can't figure out why I'm getting this error.
Код:
sscanf warning: String buffer overflow.
pawn Код:
new name[24], arr[9], farr[3], arr2[17], farr2[2];
if(!sscanf(result, "s[23]a<i>[9]a<f>[3]a<i>[17]a<f>[2]", name, arr, farr, arr2, farr2))
{
printf(result);
strmid(PlayerInfo[playerid][pUsername], name, 0, strlen(name), 255);
PlayerInfo[playerid][pSQLid] = arr[0];
PlayerInfo[playerid][pPassword] = arr[1];
PlayerInfo[playerid][pLevel] = arr[2];
PlayerInfo[playerid][pAdmin] = arr[3];
PlayerInfo[playerid][pCash] = arr[4];
PlayerInfo[playerid][pBank] = arr[5];
PlayerInfo[playerid][pSkin] = arr[6];
PlayerInfo[playerid][pSex] = arr[7];
PlayerInfo[playerid][pAge] = arr[8];
PlayerInfo[playerid][pPos_x] = farr[0];
PlayerInfo[playerid][pPos_y] = farr[1];
PlayerInfo[playerid][pPos_z] = farr[2];
PlayerInfo[playerid][pInt] = arr2[0];
PlayerInfo[playerid][pFaction] = arr2[1];
PlayerInfo[playerid][pRank] = arr2[2];
PlayerInfo[playerid][pMask] = arr2[3];
PlayerInfo[playerid][pPhone] = arr2[4];
PlayerInfo[playerid][pMuted] = arr2[5];
PlayerInfo[playerid][pWarns] = arr2[6];
PlayerInfo[playerid][pPayday] = arr2[7];
PlayerInfo[playerid][pInBiz] = arr2[8];
PlayerInfo[playerid][pInHouse] = arr2[9];
PlayerInfo[playerid][pDuty] = arr2[10];
PlayerInfo[playerid][pDutySkin] = arr2[11];
PlayerInfo[playerid][pCuffed] = arr2[12];
PlayerInfo[playerid][pCuffTime] = arr2[13];
PlayerInfo[playerid][pJailed] = arr2[14];
PlayerInfo[playerid][pJailTime] = arr2[15];
PlayerInfo[playerid][pJob] = arr2[16];
PlayerInfo[playerid][pHealth] = farr2[0];
PlayerInfo[playerid][pArmour] = farr2[1];
mysql_free_result();
}
Re: String Buffer Overflow -
Krx17 - 08.02.2011
Are you using the plugin sscanf or the stock?
Re: String Buffer Overflow -
__ - 08.02.2011
You're trying to unload a value to a variable that exceeds the size defined for the string.
i.e: Attempting to write "asdasdas" to a string with 2 cells, a buffer overflow was caused because the content exceeds 2 cells.
Re: String Buffer Overflow -
Antonio [G-RP] - 08.02.2011
@Krx17, I'm using the plugin.
@___, But, for SA-MP names isn't there a maximum amount of characters in a name at 20? Or are you talking about the whole sscanf statement?
Re: String Buffer Overflow -
Rachael - 08.02.2011
it is just a warning, and suggests that you should check your string lengths.
eg your name variable is 24, and you told sscanf that it is 23, I would start there.
To find out exactly where the warning is occuring, try adding the parameters to the sscanf specifiers one at a time.
Particularly with the array specifier, as the specifier a<i>[2] might require an array of size [3] to work properly ( not sure about this but it is worth looking at )
Re: String Buffer Overflow -
Antonio [G-RP] - 08.02.2011
Both things that you told me to correct were taught to me by a good friend, who knows plenty about mysql and sscanf. Ofcourse, I'll check the name variable, it's always looked a bit odd to me.
As for the array specifiers, I know those aren't the problems.
Re: String Buffer Overflow -
Krx17 - 08.02.2011
Also, the max length for a name is 24, not 20.
Re: String Buffer Overflow -
Antonio [G-RP] - 08.02.2011
Код:
Name Length 20 characters.
https://sampwiki.blast.hk/wiki/Limits
Re: String Buffer Overflow -
(SF)Noobanatior - 08.02.2011
sorry mate a_samp.inc
#define MAX_PLAYER_NAME (24)
Re: String Buffer Overflow -
Mean - 10.02.2011
Quote:
Originally Posted by Krx17
Are you using the plugin sscanf or the stock?
|
Actually it's a native, and I never got this warning.