From 80611a4186d4aa4fda481055b98e98a910c0778b Mon Sep 17 00:00:00 2001 From: Dennis Friis Date: Thu, 10 Apr 2008 17:15:31 +0000 Subject: revert rev 17 --- src/map/intif.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/map/intif.c b/src/map/intif.c index 4464dc5..ace0187 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -584,20 +584,22 @@ int mapif_parse_WisToGM(int fd) { // 0x3003/0x3803 .w .24B int i, min_gm_level; struct map_session_data *pl_sd; char Wisp_name[24]; - char *message = malloc((RFIFOW(fd,2) - 30)); + char mbuf[255]; + char *message = ((RFIFOW(fd,2) - 30) >= sizeof(mbuf)) ? (char *) malloc((RFIFOW(fd,2) - 30)) : mbuf; min_gm_level = (int)RFIFOW(fd,28); memcpy(Wisp_name, RFIFOP(fd,4), 24); Wisp_name[23] = '\0'; - memcpy(message, RFIFOP(fd,30), (RFIFOW(fd,2) - 30)); - message[RFIFOW(fd,2) - 31] = '\0'; + memcpy(message, RFIFOP(fd,30), RFIFOW(fd,2) - 30); + message[sizeof(message) - 1] = '\0'; // information is sended to all online GM for (i = 0; i < fd_max; i++) if (session[i] && (pl_sd = session[i]->session_data) && pl_sd->state.auth) if (pc_isGM(pl_sd) >= min_gm_level) clif_wis_message(i, Wisp_name, message, strlen(message) + 1); - free(message); + if (message != mbuf) + free(message); return 0; } -- cgit v1.2.3-70-g09d2