[Crash Fix] Character Creation Class/Race out of Range. (#3920)

* [Crash Fix] Character Creation Class/Race out of Range.

Known bug to crash the world server from character creation.

You can send a packet with a manual race or class entry below 0 or above 255 will cause world crash.

* Requested changes

* Compile fixes and logging change

* Fixed compile issues
This commit is contained in:
Fryguy 2024-01-08 23:24:15 -05:00 committed by GitHub
parent 472dd71d7f
commit e035660150
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,7 @@
#include "../common/random.h"
#include "../common/shareddb.h"
#include "../common/opcodemgr.h"
#include "../common/data_verification.h"
#include "client.h"
#include "worlddb.h"
@ -535,10 +536,21 @@ bool Client::HandleNameApprovalPacket(const EQApplicationPacket *app)
}
auto length = snprintf(char_name, 64, "%s", (char*)app->pBuffer);
uchar race = app->pBuffer[64];
uchar clas = app->pBuffer[68];
LogInfo("Name approval request. Name=[{}], race=[{}], class=[{}]", char_name, GetRaceIDName(race), GetClassIDName(clas));
uchar race_selection = app->pBuffer[64];
uchar class_selection = app->pBuffer[68];
if (!IsPlayerRace(race_selection)) {
LogInfo("Invalid Race ID.");
return false;
}
if (!EQ::ValueWithin(class_selection, Class::Warrior, Class::Berserker)) {
LogInfo("Invalid Class ID.");
return false;
}
LogInfo("Name approval request. Name=[{}], race_selection=[{}], class=[{}]", char_name, GetRaceIDName(race_selection), GetClassIDName(class_selection));
EQApplicationPacket *outapp;
outapp = new EQApplicationPacket;