From 9ea6aabe0e3bbf666b1b881850ac10a62f1b8521 Mon Sep 17 00:00:00 2001
From: HarpyWar <harpywar@gmail.com>
Date: Thu, 26 Jun 2014 16:14:15 +0400
Subject: [PATCH] fix truncate message text

---
 src/bnetd/message.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/bnetd/message.cpp b/src/bnetd/message.cpp
index bfc53d5..d71e62a 100644
--- a/src/bnetd/message.cpp
+++ b/src/bnetd/message.cpp
@@ -990,12 +990,13 @@ namespace pvpgn
 			if (text && text[0] == '\0')
 				text = " "; /* empty messages crash some clients, just send whitespace */
 
+			std::string temp;
 			if (text && (std::strlen(text) > MAX_MESSAGE_LEN)) {
 				/* PELISH: We are trying to support MAX_IRC_MESSAGE_LEN for IRC and also
 						   MAX_MESSAGE_LEN for bnet */
-				char * temp = (char *)text;
 				eventlog(eventlog_level_warn, __FUNCTION__, "line too long, truncation...");
-				temp[MAX_MESSAGE_LEN] = '\0';
+				temp = std::string(text, text + MAX_MESSAGE_LEN);
+				text = temp.c_str();
 			}
 
 			packet_set_size(packet, sizeof(t_server_message));