gm_tmysql4 icon indicating copy to clipboard operation
gm_tmysql4 copied to clipboard

Odd issue with error handling

Open VaasKahnGrim opened this issue 4 years ago • 2 comments

Basically when ever there is an error for tmysql its not displaying the full error for me. I'm currently using the mysql.lua file from Dash along with this version of tmysql.

As for where the error is originating, I know for a fact its in the callback function of DB:Query(), however I can't get any sort of info on where in the callback the error is happening at sql_errors_broken

VaasKahnGrim avatar Jan 16 '21 20:01 VaasKahnGrim

The handling also majorly broken if you make syntax mistakes in SQL. It will return corrupt error messages (which can signal memory corruption), and it will probably crash your server shortly after error.

osiris-plus avatar Apr 04 '21 08:04 osiris-plus

There was a difference in behavior for error messages between regular queries and prepared statements that should have been fixed in the latest commit - prepared statements weren't always returning anything useful with their error method

KingofBeast avatar Apr 04 '21 15:04 KingofBeast

https://github.com/SuperiorServers/gm_tmysql4/blob/master/src/database.cpp#L182

The issue is with the use of qErr.c_str() here, which causes "use after free" for that region of memory that is passed to Lua state.

@aStonedPenguin

osiris-plus avatar Feb 21 '25 18:02 osiris-plus