ZhengPeiRu21 / mod-playerbots

AzerothCore Playerbots Module
MIT License
194 stars 93 forks source link

Playerbot console commands cause server crash due to SQL malformed query. #128

Closed drozco closed 1 year ago

drozco commented 1 year ago

Console commands such as:

causes a worldserver crash due to a SQL statement error.

This is due to: RandomPlayerbotMgr.cpp line ~1714 in method HandlePlayerbotConsoleCommand: if (QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters WHERE account = {} AND name like {}", account, name.c_str()))

missing quote around the 'name' field. The code should read like this: if (QueryResult results = CharacterDatabase.Query("SELECT guid FROM characters WHERE account = {} AND name like '{}'", account, name.c_str()))

corker22 commented 1 year ago

im looking and a number of difference query's and a number of them don't have those quests. don't know anything about sql how do you know when you need them or don't

drozco commented 1 year ago

Well if it's a text you need the quotes like a char name but if its a number it's optional. So in this case account = # is OK but name like needs a quote.

corker22 commented 1 year ago

does this effect read and write or just one or the other? i only ask cause i'm following 2 bots xp one my own alt and a random bot my alt does update, but the random bot has been at 6250 for an hour... only thing i can figure is either 1 the update is written wrong or 2 i don't have permission to update those random bot accounts. update i hearthed and summoned the bots then the random bot updated...

ZhengPeiRu21 commented 1 year ago

Thank you so much for report this issue and detailing the fix. Fix is committed in https://github.com/ZhengPeiRu21/mod-playerbots/commit/7c16f2ae48926be0af20f921774dc335f1b74124.