Fixed a crash with unknown packets (#8437)

Fixes #8432

Thanks to @gmragnarok
This commit is contained in:
Lemongrass3110 2024-06-17 18:30:43 +02:00 committed by GitHub
parent 6451925430
commit 68f8a4bc7f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1594,6 +1594,8 @@ int chclif_parse(int fd) {
// Before processing any other packets, do a few checks
default:
// To reach this block the client should have attained a session already
if( sd != nullptr ){
// If the pincode was entered correctly
if( sd->pincode_correct ){
break;
@ -1607,6 +1609,12 @@ int chclif_parse(int fd) {
// The pincode was not entered correctly, yet the player (=bot) tried to send a different packet => Goodbye!
set_eof( fd );
return 0;
}else{
// Unknown packet received
ShowError( "chclif_parse: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", cmd, ip2str( ipl, nullptr ) );
set_eof( fd );
return 0;
}
}
}
#endif
@ -1654,7 +1662,7 @@ int chclif_parse(int fd) {
break;
// unknown packet received
default:
ShowError("parse_char: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", RFIFOW(fd,0), ip2str(ipl, nullptr));
ShowError( "chclif_parse: Received unknown packet " CL_WHITE "0x%x" CL_RESET " from ip '" CL_WHITE "%s" CL_RESET "'! Disconnecting!\n", cmd, ip2str( ipl, nullptr ) );
set_eof(fd);
return 0;
}