AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Help with MYSQL Leak (https://forums.alliedmods.net/showthread.php?t=274591)

shadowdragon 11-10-2015 19:35

Help with MYSQL Leak
 
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);



Miu 11-10-2015 19:57

Re: Help with MYSQL Leak
 
code might help

shadowdragon 11-10-2015 20:14

Re: Help with MYSQL Leak
 
Woops i completely forgot ill add that now.

Potato Uno 11-10-2015 20:31

Re: Help with MYSQL Leak
 
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.)

shadowdragon 11-10-2015 20:39

Re: Help with MYSQL Leak
 
Ok thanks.

psychonic 11-10-2015 22:13

Re: Help with MYSQL Leak
 
Quote:

Originally Posted by Potato Uno (Post 2361915)
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).

shadowdragon 11-11-2015 01:08

Re: Help with MYSQL Leak
 
Could you please give me an example on how to validate a steamid? or do i just set GetClientAuthId end argument to true?

DarkDeviL 11-11-2015 01:50

Re: Help with MYSQL Leak
 
Quote:

Originally Posted by shadowdragon (Post 2361950)
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... */



shadowdragon 11-11-2015 23:23

Re: Help with MYSQL Leak
 
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.


All times are GMT -4. The time now is 13:46.

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