diff --git a/indra/llmessage/lltemplatemessagebuilder.cpp b/indra/llmessage/lltemplatemessagebuilder.cpp
index 55379fc6fdcb6beaa487191899b153410b3ef813..fa02456d90c93d02fbf2539b4005edb10029a512 100644
--- a/indra/llmessage/lltemplatemessagebuilder.cpp
+++ b/indra/llmessage/lltemplatemessagebuilder.cpp
@@ -326,7 +326,7 @@ void LLTemplateMessageBuilder::addData(const char *varname, const void *data, EM
 			       << "(" << size << ").  Clamping size and truncating data." << llendl;
 			size = 255;
 			char *truncate = (char *)data;
-			truncate[255] = 0;
+			truncate[254] = 0; // array size is 255 but the last element index is 254
 		}
 
 		// no correct size for MVT_VARIABLE, instead we need to tell how many bytes the size will be encoded as
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 6682575ca58c71fe2a3dd833ce603f4ca1331452..8f56cf252172aa2d9090b4462eb0f2b1be632253 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -433,10 +433,9 @@ inline void LLTemplateMessageReader::getString(const char *block, const char *va
 
 inline void LLTemplateMessageReader::getString(const char *block, const char *var, std::string& outstr, S32 blocknum )
 {
-	char s[MTUBYTES];
-	s[0] = '\0';
+	char s[MTUBYTES + 1]= {0}; // every element is initialized with 0
 	getData(block, var, s, 0, blocknum, MTUBYTES);
-	s[MTUBYTES - 1] = '\0';
+	s[MTUBYTES] = '\0';
 	outstr = s;
 }
 
diff --git a/indra/newview/skins/default/xui/en/panel_edit_profile.xml b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
index 26be8440e7c0663f4f2a331d87c5546fa8debb2d..dff2b9a214f2f1c35bb595bb117b82f79358d064 100644
--- a/indra/newview/skins/default/xui/en/panel_edit_profile.xml
+++ b/indra/newview/skins/default/xui/en/panel_edit_profile.xml
@@ -146,7 +146,7 @@
        layout="topleft"
        left="123"
        top="25"
-       max_length="512"
+       max_length="511"
        name="sl_description_edit"
        width="157"
        word_wrap="true">
@@ -200,7 +200,7 @@
        height="102"
        layout="topleft"
        left="123"
-       max_length="512"
+       max_length="254"
        top="157"
        name="fl_description_edit"
        width="157"