You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
I can always reproduce the issue with the provided description below.
Environment
Operating System version: ubuntu 20.04
Game/AppID (with version if applicable): 440
Current SourceMod version: 1.12
Current SourceMod snapshot: 7125
Current Metamod: Source snapshot: 1.12.0-dev+1192
I have updated SourceMod to the latest version and it still happens.
I have updated SourceMod to the latest snapshot and it still happens.
I have updated SourceMM to the latest snapshot and it still happens.
Description
When using admin-sql-threaded.smx, the error in the picture is thrown when an admin joins a server.
The SQL Query in the SELECT statement in lines 510-529 has incorrect syntax. COUNT() is an aggregate function, and so all values that aren't in an aggregate function must be in the GROUP BY clause. However, adding all the additional columns needed causes the SQL query to get truncated so the length of the array should be increased.
Problematic Code (or Steps to Reproduce)
Lines 510-529
// Increase the char buffer's size or the query gets truncated with the new GROUP BY clause
char query[512];
int len = 0;
len += Format(query[len], sizeof(query)-len, "SELECT a.id, a.authtype, a.identity, a.password, a.flags, a.name, COUNT(ag.group_id), immunity");
len += Format(query[len], sizeof(query)-len, " FROM sm_admins a LEFT JOIN sm_admins_groups ag ON a.id = ag.admin_id WHERE ");
len += Format(query[len], sizeof(query)-len, " (a.authtype = 'ip' AND a.identity = '%s')", ipaddr);
len += Format(query[len], sizeof(query)-len, " OR (a.authtype = 'name' AND a.identity = '%s')", safe_name);
if (steamid2[0] != '\0' && steamid3[0] != '\0' && steamid64[0] != '\0')
{
strcopy(steamid2alt, sizeof(steamid2alt), steamid2);
steamid2alt[6] = (steamid2[6] == '0') ? '1' : '0';
len += Format(query[len], sizeof(query)-len,
" OR (a.authtype = 'steam' AND (a.identity = '%s' OR a.identity = '%s' OR a.identity = '%s' OR a.identity = '%s'))",
steamid2, steamid2alt, steamid3, steamid64);
}
// Should be: GROUP BY a.id, a.authtype, a.identity, a.password, a.flags, a.name, immunity
len += Format(query[len], sizeof(query)-len, " GROUP BY a.id");
Logs
Please attach in separate files: game output, library logs, kernel logs, and any other supporting information.
In case of a crash, please attach minidump or dump analyze output.
The text was updated successfully, but these errors were encountered:
ArcalaAlien
changed the title
admin-sql-threaded: SQL Query has improper syntax and is truncated when called in FetchUser()
admin-sql-threaded: SQL Query has improper syntax in FetchUser()
May 4, 2024
Help us help you
Environment
Description
When using admin-sql-threaded.smx, the error in the picture is thrown when an admin joins a server.
The SQL Query in the SELECT statement in lines 510-529 has incorrect syntax. COUNT() is an aggregate function, and so all values that aren't in an aggregate function must be in the GROUP BY clause. However, adding all the additional columns needed causes the SQL query to get truncated so the length of the array should be increased.
Problematic Code (or Steps to Reproduce)
Lines 510-529
Logs
The text was updated successfully, but these errors were encountered: