diff --git a/indra/llmessage/lldatapacker.h b/indra/llmessage/lldatapacker.h index b0a638c16e..940c797b77 100644 --- a/indra/llmessage/lldatapacker.h +++ b/indra/llmessage/lldatapacker.h @@ -199,9 +199,18 @@ inline BOOL LLDataPackerBinaryBuffer::verifyLength(const S32 data_size, const ch { if (mWriteEnabled && (mCurBufferp - mBufferp) > mBufferSize - data_size) { - llwarns << "Buffer overflow in BinaryBuffer length verify, field name " << name << "!" << llendl; - llwarns << "Current pos: " << (int)(mCurBufferp - mBufferp) << " Buffer size: " << mBufferSize << " Data size: " << data_size << llendl; - return FALSE; + // Handle invalid packets by throwing an exception and a graceful continue + + // llwarns << "Buffer overflow in AsciiBuffer length verify, field name " << name << "!" << llendl; + // llwarns << "Current pos: " << (int)(mCurBufferp - mBufferp) << " Buffer size: " << mBufferSize << " Data size: " << data_size << llendl; + // return FALSE; + + std::stringstream strm; + strm << "Buffer overflow in BinaryBuffer length verify, field name " << name << "!" << std::endl; + strm << "Current pos: " << (int)(mCurBufferp - mBufferp) << " Buffer size: " << mBufferSize << " Data size: " << data_size << std::endl; + throw std::string( strm.str() ); + + // } return TRUE; diff --git a/indra/llmessage/llmessagetemplate.h b/indra/llmessage/llmessagetemplate.h index 16d825d33b..370810e688 100644 --- a/indra/llmessage/llmessagetemplate.h +++ b/indra/llmessage/llmessagetemplate.h @@ -365,7 +365,22 @@ public: if (mHandlerFunc) { LLPerfBlock msg_cb_time("msg_cb", mName); - mHandlerFunc(msgsystem, mUserData); + + // Handle invalid packets by throwing an exception and a graceful continue + + // mHandlerFunc(msgsystem, mUserData); + + try + { + mHandlerFunc(msgsystem, mUserData); + } + catch( std::string &why ) + { + llwarns << why << llendl; + } + + // + return TRUE; } return FALSE; diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index ab91f74abe..f10098039b 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -508,21 +508,41 @@ BOOL LLTemplateMessageReader::decodeTemplate( void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted ) { + // Handle invalid packets by throwing an exception and a graceful continue + // we've run off the end of the packet! - llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName + +// llwarns << "Ran off end of packet " << mCurrentRMessageTemplate->mName +// // << " with id " << mCurrentRecvPacketID +// << " from " << host +// << " trying to read " << wanted +// << " bytes at position " << where +// << " going past packet end at " << mReceiveSize +// << llendl; +// if(gMessageSystem->mVerboseLog) +// { +// llinfos << "MSG: -> " << host << "\tREAD PAST END:\t" +// // << mCurrentRecvPacketID << " " +// << getMessageName() << llendl; +// } +// gMessageSystem->callExceptionFunc(MX_RAN_OFF_END_OF_PACKET); + + std::stringstream strm; + strm << "Ran off end of packet " << mCurrentRMessageTemplate->mName // << " with id " << mCurrentRecvPacketID << " from " << host << " trying to read " << wanted << " bytes at position " << where << " going past packet end at " << mReceiveSize - << llendl; + << std::endl; if(gMessageSystem->mVerboseLog) { - llinfos << "MSG: -> " << host << "\tREAD PAST END:\t" + strm << "MSG: -> " << host << "\tREAD PAST END:\t" // << mCurrentRecvPacketID << " " - << getMessageName() << llendl; + << getMessageName() << std::endl; } gMessageSystem->callExceptionFunc(MX_RAN_OFF_END_OF_PACKET); + throw std::string( strm.str() ); } static LLFastTimer::DeclareTimer FTM_PROCESS_MESSAGES("Process Messages");