From b258a76313a6273c645d419eb360468a78840200 Mon Sep 17 00:00:00 2001 From: eathenabot Date: Thu, 31 May 2012 05:28:43 +0000 Subject: * Merged changes up to eAthena 15111. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@16175 54d463be-8e91-2dee-dedb-b68131a5f0ec --- src/map/clif.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 97e96ec8e..56f1deb6d 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5316,12 +5316,14 @@ void clif_displaymessage(const int fd, const char* mes) message = aStrdup(mes); line = strtok(message, "\n"); while(line != NULL) { - int len = strlen(line); + // Limit message to 255+1 characters (otherwise it causes a buffer overflow in the client) + int len = strnlen(line, 255); + if (len > 0) { // don't send a void message (it's not displaying on the client chat). @help can send void line. WFIFOHEAD(fd, 5 + len); WFIFOW(fd,0) = 0x8e; WFIFOW(fd,2) = 5 + len; // 4 + len + NULL teminate - memcpy(WFIFOP(fd,4), line, len + 1); + safestrncpy(WFIFOP(fd,4), line, len + 1); WFIFOSET(fd, 5 + len); } line = strtok(NULL, "\n"); -- cgit v1.2.3-70-g09d2