summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorKelly Washington <kelly@lindenlab.com>2012-04-25 11:26:54 -0700
committerKelly Washington <kelly@lindenlab.com>2012-04-25 11:26:54 -0700
commit6d3be57d334f02f4781dcaede9746976bd3643a4 (patch)
treec6cfd48813762cf55f67459e8b7797c86ba68475 /indra/llui
parent4472354b5454f758c467bb23190d1a84cf61d909 (diff)
SEC-995 FIX viewer is easily spammed to death by chat
removed a couple more unnecessary string copies from unfortunate LLSD behavior. reviewed with simon, post review from Richard.
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/lltextbase.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index c2cd590acb..813f919505 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -280,11 +280,23 @@ bool LLTextBase::truncate()
if (getLength() >= S32(mMaxTextByteLength / 4))
{
// Have to check actual byte size
- S32 utf8_byte_size = getViewModel()->getValue().asString().size();
+ S32 utf8_byte_size = 0;
+ LLSD value = getViewModel()->getValue();
+ if (value.type() == LLSD::TypeString)
+ {
+ // save a copy for strings.
+ utf8_byte_size = value.size();
+ }
+ else
+ {
+ // non string LLSDs need explicit conversion to string
+ utf8_byte_size = value.asString().size();
+ }
+
if ( utf8_byte_size > mMaxTextByteLength )
{
// Truncate safely in UTF-8
- std::string temp_utf8_text = getViewModel()->getValue().asString();
+ std::string temp_utf8_text = value.asString();
temp_utf8_text = utf8str_truncate( temp_utf8_text, mMaxTextByteLength );
LLWString text = utf8str_to_wstring( temp_utf8_text );
// remove extra bit of current string, to preserve formatting, etc.