From 870bb8ef381364883fb066aa35c7553311233f76 Mon Sep 17 00:00:00 2001 From: Vatiken Date: Fri, 2 Mar 2012 08:43:06 +0000 Subject: [PATCH] Should fix the 'crash' bug related to input > 2 kb, as well as fix the mobile deletion crash bug, also a small memory leak plugged --- lib/misc/typos | 10 ++++++++++ src/comm.c | 2 +- src/genmob.c | 34 +++++++++++++++++++++++++++++++++- src/protocol.c | 2 ++ src/protocol.h | 2 +- 5 files changed, 47 insertions(+), 3 deletions(-) diff --git a/lib/misc/typos b/lib/misc/typos index e69de29..e008d7d 100644 --- a/lib/misc/typos +++ b/lib/misc/typos @@ -0,0 +1,10 @@ +Text test~ +Body a test +~ +Name Taoth~ +IdNum 3 +Dated 1329779435 +Level 1 +Room 3001 +Flags 0 0 0 0 +End diff --git a/src/comm.c b/src/comm.c index 6adabff..5b4b37e 100644 --- a/src/comm.c +++ b/src/comm.c @@ -1906,7 +1906,7 @@ static int process_input(struct descriptor_data *t) return (-1); } - bytes_read = perform_socket_read(t->descriptor, read_buf, MAX_PROTOCOL_BUFFER); + bytes_read = perform_socket_read(t->descriptor, read_buf, space_left); if ( bytes_read >= 0 ) { diff --git a/src/genmob.c b/src/genmob.c index ba74661..dc479f7 100644 --- a/src/genmob.c +++ b/src/genmob.c @@ -102,17 +102,46 @@ int copy_mobile(struct char_data *to, struct char_data *from) static void extract_mobile_all(mob_vnum vnum) { struct char_data *next, *ch; + int i; for (ch = character_list; ch; ch = next) { next = ch->next; - if (GET_MOB_VNUM(ch) == vnum) + if (GET_MOB_VNUM(ch) == vnum) { + if ((i = GET_MOB_RNUM(ch)) != NOBODY) { + if (ch->player.name && ch->player.name != mob_proto[i].player.name) + free(ch->player.name); + ch->player.name = NULL; + + if (ch->player.title && ch->player.title != mob_proto[i].player.title) + free(ch->player.title); + ch->player.title = NULL; + + if (ch->player.short_descr && ch->player.short_descr != mob_proto[i].player.short_descr) + free(ch->player.short_descr); + ch->player.short_descr = NULL; + + if (ch->player.long_descr && ch->player.long_descr != mob_proto[i].player.long_descr) + free(ch->player.long_descr); + ch->player.long_descr = NULL; + + if (ch->player.description && ch->player.description != mob_proto[i].player.description) + free(ch->player.description); + ch->player.description = NULL; + + /* free script proto list if it's not the prototype */ + if (ch->proto_script && ch->proto_script != mob_proto[i].proto_script) + free_proto_script(ch, MOB_TRIGGER); + ch->proto_script = NULL; + } extract_char(ch); + } } } int delete_mobile(mob_rnum refpt) { struct char_data *live_mob; + struct char_data *proto; int counter, cmd_no; mob_vnum vnum; zone_rnum zone; @@ -127,7 +156,10 @@ int delete_mobile(mob_rnum refpt) } vnum = mob_index[refpt].vnum; + proto = &mob_proto[refpt]; + extract_mobile_all(vnum); + extract_char(proto); for (counter = refpt; counter < top_of_mobt; counter++) { mob_index[counter] = mob_index[counter + 1]; diff --git a/src/protocol.c b/src/protocol.c index 61561d8..c699207 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -419,6 +419,8 @@ void ProtocolInput( descriptor_t *apDescriptor, char *apData, int aSize, char *a { const char *pClientName = pProtocol->pVariables[eMSDP_CLIENT_ID]->pValueString; + InfoMessage(apDescriptor, "Receiving MXP Version From Client.\r\n"); + free(pProtocol->pVariables[eMSDP_CLIENT_VERSION]->pValueString); pProtocol->pVariables[eMSDP_CLIENT_VERSION]->pValueString = AllocString(pMXPTag); diff --git a/src/protocol.h b/src/protocol.h index 4249bde..f9aa676 100644 --- a/src/protocol.h +++ b/src/protocol.h @@ -35,7 +35,7 @@ typedef struct descriptor_data descriptor_t; #define SNIPPET_VERSION 6 /* Helpful for debugging */ -#define MAX_PROTOCOL_BUFFER 2048 +#define MAX_PROTOCOL_BUFFER MAX_RAW_INPUT_LENGTH #define MAX_VARIABLE_LENGTH 4096 #define MAX_OUTPUT_BUFFER LARGE_BUFSIZE #define MAX_MSSP_BUFFER 4096