Go Back   EQEmulator Home > EQEmulator Forums > Development > Development::Server Code Submissions

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2014, 09:12 PM
image
Demi-God
 
Join Date: Jan 2002
Posts: 1,290
Default OP_Emote client crash fix

Code:
void Client::Handle_OP_Emote(const EQApplicationPacket *app)
{
	if(app->size != sizeof(Emote_Struct)) {
		LogFile->write(EQEMuLog::Error, "Received invalid sized "
			"OP_Emote: got %d, expected %d", app->size,
			sizeof(Emote_Struct));
		DumpPacket(app);
		return;
	}

	// Calculate new packet dimensions
	Emote_Struct* in	= (Emote_Struct*)app->pBuffer;
	const char* name	= GetName();
	uint32 len_name		= strlen(name);
	uint32 len_msg		= strnlen(in->message,958);
	uint32 len_packet	= sizeof(in->unknown01) + len_name
		+ len_msg + 1;

	// Construct outgoing packet
	EQApplicationPacket* outapp = new EQApplicationPacket(OP_Emote, len_packet);
	Emote_Struct* out = (Emote_Struct*)outapp->pBuffer;
	out->unknown01 = in->unknown01;
	memcpy(out->message, name, len_name);

	memcpy(&out->message[len_name], in->message, len_msg);

	out->message[len_name] = 0x20;
	out->message[len_name + len_msg - 1] = '\0';

	entity_list.QueueCloseClients(this, outapp, true, 100,0,true,FILTER_SOCIALS);

	safe_delete(outapp);
	return;
}
For other char arrays from client:

Code:
int Client::sanitizeCharArray(char* inArray, char* outData, int maxLength)
{
	int length = strnlen(inArray,maxLength);
	strncpy(outData,inArray,length);
	outData[length] = '\0';
	return length;
}
example:


char targetName[64];
int targetLength = sanitizeCharArray(c->name, (char*)targetName, 64);

Opcodes that have char arrays of concern:

Handle_OP_Consent
Handle_OP_ConsentDeny
Handle_OP_Surname
Handle_OP_ChannelMessage
Handle_OP_GMLastName
Handle_OP_LFGCommand
Handle_OP_GroupInvite2
Handle_OP_GroupCancelInvite
Handle_OP_InspectAnswer
__________________
www.eq2emu.com
EQ2Emu Developer
Former EQEMu Developer / GuildWars / Zek Seasons Servers
Member of the "I hate devn00b" club.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 10:38 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3