diff options
author | Karen Clark <karen@lindenlab.com> | 2007-03-20 22:21:42 +0000 |
---|---|---|
committer | Karen Clark <karen@lindenlab.com> | 2007-03-20 22:21:42 +0000 |
commit | fceae96eb171be0396512e251aab311d4e3ef9cc (patch) | |
tree | e648d1dd42aeae4d47168bd8d696ff0895819b8b /indra/llmessage/llinstantmessage.cpp | |
parent | 5e9e67cb2d1d3dfc82dfe96103270b2341991ddd (diff) |
svn merge -r59459:59476 svn+ssh://svn.lindenlab.com/svn/linden/branches/adroit.r69-75_2 into svn+ssh://svn.lindenlab.com/svn/linden/release.
Diffstat (limited to 'indra/llmessage/llinstantmessage.cpp')
-rw-r--r-- | indra/llmessage/llinstantmessage.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/indra/llmessage/llinstantmessage.cpp b/indra/llmessage/llinstantmessage.cpp index ecdc9e6dc3..944785c3a5 100644 --- a/indra/llmessage/llinstantmessage.cpp +++ b/indra/llmessage/llinstantmessage.cpp @@ -207,8 +207,21 @@ void pack_instant_message_block( S32 bytes_left = MTUBYTES; if(message) { - char buffer[MTUBYTES]; /*Flawfinder: ignore*/ - bytes_left -= snprintf(buffer, MTUBYTES, "%s", message); /*Flawfinder: ignore*/ + char buffer[MTUBYTES]; + int num_written = snprintf(buffer, MTUBYTES, "%s", message); /* Flawfinder: ignore */ + // snprintf returns number of bytes that would have been written + // had the output not being truncated. In that case, it will + // return either -1 or value >= passed in size value . So a check needs to be added + // to detect truncation, and if there is any, only account for the + // actual number of bytes written..and not what could have been + // written. + if (num_written < 0 || num_written >= MTUBYTES) + { + num_written = MTUBYTES - 1; + llwarns << "pack_instant_message_block: message truncated: " << message << llendl; + } + + bytes_left -= num_written; bytes_left = llmax(0, bytes_left); msg->addStringFast(_PREHASH_Message, buffer); } |