Sfoglia il codice sorgente

* Merged changes up to eAthena 15111.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@16175 54d463be-8e91-2dee-dedb-b68131a5f0ec
eathenabot 13 anni fa
parent
commit
d3ba34e417
1 ha cambiato i file con 4 aggiunte e 2 eliminazioni
  1. 4 2
      src/map/clif.c

+ 4 - 2
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");