Raised This Month: $32 Target: $400
 8% 

Help with MYSQL Leak


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadowdragon
Senior Member
Join Date: Dec 2012
Old 11-10-2015 , 19:35   Help with MYSQL Leak
Reply With Quote #1

Hey all what are the common problems for data leaking into other players stats for example my plugin im making that stores points will some times give the next player that joins the same points loaded for the first player. Iv rewriten my mysql part of my plugin 3 times now all using different ways to save/load data but it still leaks data. is there a reason for this and can someone explain how i can fix it.

PHP Code:
public DataLoad(client)
{
    
decl String:query[400], String:auth[400];
    
GetClientAuthId(clientAuthId_Steam3,authsizeof(auth));
    
FormatEx(querysizeof(query), "SELECT * FROM XXXx WHERE steamid = '%s'"auth);
    
SQL_TQuery(hDatabaseStore_Load_Dataqueryclient);
}
public 
DataSave(client)
{
    if (!
IsClientInGame(client))
        return;
    
    
decl String:query[400], String:auth[400], String:name[200];
    
GetClientName(clientnamesizeof(name));
    
GetClientAuthId(clientAuthId_Steam3,authsizeof(auth));
    
FormatEx(querysizeof(query), "UPDATE XXXx SET Credits = %d, Name = '%s', Trails = %d, Tags = %d, Tier = %d WHERE steamid = '%s'"Credits[client],name,Trails[client],Tags[client], Tier[client], auth);
    
SQL_TQuery(hDatabaseT_Savequeryclient);

__________________
Sorry for my poor English!
________________________________
I can do CSS/CSGO plugin request for little money!

Last edited by shadowdragon; 11-10-2015 at 20:17.
shadowdragon is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 11-10-2015 , 19:57   Re: Help with MYSQL Leak
Reply With Quote #2

code might help
Miu is offline
shadowdragon
Senior Member
Join Date: Dec 2012
Old 11-10-2015 , 20:14   Re: Help with MYSQL Leak
Reply With Quote #3

Woops i completely forgot ill add that now.
__________________
Sorry for my poor English!
________________________________
I can do CSS/CSGO plugin request for little money!
shadowdragon is offline
Potato Uno
Veteran Member
Join Date: Jan 2014
Location: Atlanta, Georgia
Old 11-10-2015 , 20:31   Re: Help with MYSQL Leak
Reply With Quote #4

It looks fine to me. I would use print statements in code when a client joins and disconnects, and trace your code's execution that way.

The only way I can possibly think that this code bugs out, assuming this is the only querying code that exists, is if GetClientAuthString is busted on SM's end and it returns the wrong steam ID somehow. (I vaguely remember this being an actual bug... though I'm not entirely sure.)
Potato Uno is offline
shadowdragon
Senior Member
Join Date: Dec 2012
Old 11-10-2015 , 20:39   Re: Help with MYSQL Leak
Reply With Quote #5

Ok thanks.
__________________
Sorry for my poor English!
________________________________
I can do CSS/CSGO plugin request for little money!
shadowdragon is offline
psychonic

BAFFLED
Join Date: May 2008
Old 11-10-2015 , 22:13   Re: Help with MYSQL Leak
Reply With Quote #6

Quote:
Originally Posted by Potato Uno View Post
The only way I can possibly think that this code bugs out, assuming this is the only querying code that exists, is if GetClientAuthString is busted on SM's end and it returns the wrong steam ID somehow. (I vaguely remember this being an actual bug... though I'm not entirely sure.)
It's not an actual bug in SM, but rather a misuse of the API.

If a client's Steam ID isn't validated yet, and calling GetClientAuthId with validate=true, and the client's ID isn't validated by Steam yet, and not checking for GetClientAuthId returning false (failure), and using decl instead of new (or the transitional syntax), you can have another client's Steam ID (or just garbage) in the buffer, since decl doesn't initialize it to anything.

TL;DR, don't use decl, and check the return of GetClientAuthId (or pass "false" for validate, but ONLY if you know what you're doing and it's safe to do so in your case).

Last edited by psychonic; 11-10-2015 at 22:14.
psychonic is offline
shadowdragon
Senior Member
Join Date: Dec 2012
Old 11-11-2015 , 01:08   Re: Help with MYSQL Leak
Reply With Quote #7

Could you please give me an example on how to validate a steamid? or do i just set GetClientAuthId end argument to true?
__________________
Sorry for my poor English!
________________________________
I can do CSS/CSGO plugin request for little money!
shadowdragon is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 11-11-2015 , 01:50   Re: Help with MYSQL Leak
Reply With Quote #8

Quote:
Originally Posted by shadowdragon View Post
Could you please give me an example on how to validate a steamid? or do i just set GetClientAuthId end argument to true?
PHP Code:
if (GetClientAuthId(clientAuthId_Steam3,authsizeof(auth))) {
  
/* Do whatever you want with client's data here... */

__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
shadowdragon
Senior Member
Join Date: Dec 2012
Old 11-11-2015 , 23:23   Re: Help with MYSQL Leak
Reply With Quote #9

Thanks for that. I have tryed it and allowed up to 30-40 people to use the store database how ever out of the 40 5-10 seem to have duplicated data i dont know why its still leaking data from others.
__________________
Sorry for my poor English!
________________________________
I can do CSS/CSGO plugin request for little money!
shadowdragon is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:28.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode