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



MySQL sscanf warning: String buffer overflow - Patrick - 21.02.2013

Hello guys. me and my friend are trying to make MySQL saving.
but everytime i register/login it shows on console sscanf warning: String buffer overflow
does anyone know how to fix it?

pawn Код:
sscanf(Query, "e<p<|>s[32]s[300]dddddddddddddddddddds[128]d>",user,pass, BankCash[playerid],money,score,CanUseArmy[playerid],CanUseCIA[playerid],AdminLevel[playerid],IsRegularPlayer[playerid],NameBanned[playerid],DrugHouseOwner[playerid],OttoOwner[playerid],TerroristSkill[playerid],RobSkill[playerid],HasPackC4[playerid],HasPackRope[playerid],HasPackMoney[playerid],
        SavedWantedLevel[playerid],SavedJailTime[playerid],Coprank[playerid],TotalPlayedTime[playerid][0],TotalPlayedTime[playerid][1],TotalPlayedTime[playerid][2],pIp,banned);
Regards
PDS2012


Re: sscanf warning: String buffer overflow - Scenario - 21.02.2013

pawn Код:
e<p<|>s[32]s[300]dddddddddddddddddddds[128]d>
should be:

pawn Код:
p<|>e<s[32]s[300]dddddddddddddddddddds[128]d>
EDIT: That could be wrong, actually.

How long is your query string?


Re: sscanf warning: String buffer overflow - Skaizo - 21.02.2013

max length is 25,i don't know how much must maxium lenght
but you have
e|p<|>
must be
p<|>


Re: sscanf warning: String buffer overflow - Patrick - 21.02.2013

@RealCop Thanks, I will try that.
- My query string is 1500, I increased it already

EDIT -It still give's me sscanf warning: String buffer overflow warning


Re: sscanf warning: String buffer overflow - Scenario - 21.02.2013

I'm thinking that one of your specifiers isn't being given the proper cell size, then. Try increasing them all a bit.


Re: sscanf warning: String buffer overflow - Patrick - 21.02.2013

I've figured out it's the password specifier, the second one with a cell size of, 300. We use Whirlpool for the hash function, and it works fine on the smaller passwords, on the big ones, it overflows.


Re: sscanf warning: String buffer overflow - Patrick - 21.02.2013

pawn Код:
password: patrick1 = Hash = Letters and Numbers: 123
5820F24A996444514B632AD22DC6FFBC69A1EF65C891A30C232EC369C5333E53D42EF5EE6BE9FDD1700B2ECB58D378FEDF527B311EDD15CC808B2A5D28488E99

password: john = Hash = Letters and Numbers: 129
3F53FFBE4F6DE35E16FA827271D54DA9CF2C0D20F62CA470C632034BC8C583D5FB09AD74F8E6ACE64B8BE5AAFD6F473DD4A34C0856A1A4E23BF117FA4C823AF5
Why do i get warning buffer overflow? because i defined my string as 300 and the character show's only 123 and 129

Quote:
Originally Posted by ******
Посмотреть сообщение
If you are using Whirlpool then all the passwords should be the same length!
i tried it. here's the code i use
pawn Код:
new pass[300];
        WP_Hash(pass, sizeof(pass),inputtext);
but its still giving me sscanf buffer overflow warning


Re: sscanf warning: String buffer overflow - Scenario - 21.02.2013

Whirlpool hashed passwords are only 129 cells long. Technically, 128, plus 1 for the null terminator.

They shouldn't be varying in sizes.


Re: sscanf warning: String buffer overflow - Patrick - 21.02.2013

yes i did split the fields. this is my code i used
pawn Код:
mysql_fetch_row_format(Query, "|");



Re: sscanf warning: String buffer overflow - Scenario - 21.02.2013

I think I see the problem.

You aren't storing the data in an enum/array, you're storing it into individual values. So, remove the e< and the > at the end of the sscanf line- it should work.

By the way, quit PMing me about scripting issues please.