diff options
Diffstat (limited to 'indra/llmessage')
| -rw-r--r-- | indra/llmessage/CMakeLists.txt | 13 | ||||
| -rw-r--r-- | indra/llmessage/llnamevalue.cpp | 1 | ||||
| -rw-r--r-- | indra/llmessage/llproxy.cpp | 2 | ||||
| -rw-r--r-- | indra/llmessage/lltemplatemessagebuilder.cpp | 4 | ||||
| -rw-r--r-- | indra/llmessage/lltemplatemessagereader.cpp | 37 | ||||
| -rw-r--r-- | indra/llmessage/lltemplatemessagereader.h | 9 | 
6 files changed, 49 insertions, 17 deletions
| diff --git a/indra/llmessage/CMakeLists.txt b/indra/llmessage/CMakeLists.txt index b2757a7306..f661e2c348 100644 --- a/indra/llmessage/CMakeLists.txt +++ b/indra/llmessage/CMakeLists.txt @@ -3,12 +3,14 @@  project(llmessage)  include(00-Common) +if (LL_TESTS)  include(LLAddBuildTest) +endif ()  include(LLCommon)  include(LLCoreHttp) +if (LL_TESTS)  include(LLAddBuildTest) -include(Python) -include(Tut) +endif ()  include(Python)  set(llmessage_SOURCE_FILES @@ -128,6 +130,7 @@ set(llmessage_HEADER_FILES      llmessagebuilder.h      llmessageconfig.h      llmessagereader.h +    llmessagesenderinterface.h      llmessagetemplate.h      llmessagetemplateparser.h      llmessagethrottle.h @@ -194,6 +197,12 @@ target_link_libraries(  )  target_include_directories( llmessage  INTERFACE   ${CMAKE_CURRENT_SOURCE_DIR}) +if (CMAKE_CXX_COMPILER_ID MATCHES GNU) +    set_source_files_properties(llnamevalue.cpp PROPERTIES COMPILE_FLAGS -Wno-stringop-truncation) +endif () + +include(LibraryInstall) +  # tests  if (LL_TESTS)    SET(llmessage_TEST_SOURCE_FILES diff --git a/indra/llmessage/llnamevalue.cpp b/indra/llmessage/llnamevalue.cpp index 853ae7df82..05ea3f26a1 100644 --- a/indra/llmessage/llnamevalue.cpp +++ b/indra/llmessage/llnamevalue.cpp @@ -967,4 +967,3 @@ std::ostream&       operator<<(std::ostream& s, const LLNameValue &a)      }      return s;  } - diff --git a/indra/llmessage/llproxy.cpp b/indra/llmessage/llproxy.cpp index d79d5c3a11..5d105eba34 100644 --- a/indra/llmessage/llproxy.cpp +++ b/indra/llmessage/llproxy.cpp @@ -498,8 +498,6 @@ static apr_status_t tcp_blocking_handshake(LLSocket::ptr_t handle, char * dataou          rv = -1;      } -    ms_sleep(1); -      if (APR_SUCCESS == rv)      {          expected_len = maxinlen; diff --git a/indra/llmessage/lltemplatemessagebuilder.cpp b/indra/llmessage/lltemplatemessagebuilder.cpp index 758d6d343f..883c84c6a5 100644 --- a/indra/llmessage/lltemplatemessagebuilder.cpp +++ b/indra/llmessage/lltemplatemessagebuilder.cpp @@ -28,6 +28,10 @@  #include "lltemplatemessagebuilder.h" +#if __FreeBSD__ +#include <arpa/inet.h> +#endif +  #include "llmessagetemplate.h"  #include "llmath.h"  #include "llquaternion.h" diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp index b62288590e..7798e5692b 100644 --- a/indra/llmessage/lltemplatemessagereader.cpp +++ b/indra/llmessage/lltemplatemessagereader.cpp @@ -27,6 +27,10 @@  #include "linden_common.h"  #include "lltemplatemessagereader.h" +#if __FreeBSD__ +#include <arpa/inet.h> +#endif +  #include "llfasttimer.h"  #include "llmessagebuilder.h"  #include "llmessagetemplate.h" @@ -118,6 +122,9 @@ void LLTemplateMessageReader::getData(const char *blockname, const char *varname      {          switch( vardata_size )          { +        case 0: +            // This is here to prevent a memcpy from a null value which is undefined behavior. +            break;          case 1:              *((U8*)datap) = *((U8*)vardata.getData());              break; @@ -286,7 +293,7 @@ void LLTemplateMessageReader::getU8(const char *block, const char *var,  void LLTemplateMessageReader::getBOOL(const char *block, const char *var,                                            bool &b, S32 blocknum )  { -    U8 value; +    U8 value(0);      getData(block, var, &value, sizeof(U8), blocknum);      b = (bool)value;  } @@ -445,7 +452,7 @@ S32 LLTemplateMessageReader::getMessageSize() const  // Returns template for the message contained in buffer  bool LLTemplateMessageReader::decodeTemplate(          const U8* buffer, S32 buffer_size,  // inputs -        LLMessageTemplate** msg_template ) // outputs +        LLMessageTemplate** msg_template, bool custom ) // outputs  {      const U8* header = buffer + LL_PACKET_ID_SIZE; @@ -487,6 +494,7 @@ bool LLTemplateMessageReader::decodeTemplate(      }      else // bogus packet received (too short)      { +        if (!custom)          LL_WARNS() << "Packet with unusable length received (too short): "                  << buffer_size << LL_ENDL;          return(false); @@ -499,9 +507,11 @@ bool LLTemplateMessageReader::decodeTemplate(      }      else      { -        // MAINT-7482 - make viewer more tolerant of unknown messages. +        if (!custom) +        {          LL_WARNS_ONCE() << "Message #" << std::hex << num << std::dec                          << " received but not registered!" << LL_ENDL; +        }          //gMessageSystem->callExceptionFunc(MX_UNREGISTERED_MESSAGE);          return(false);      } @@ -531,7 +541,7 @@ void LLTemplateMessageReader::logRanOffEndOfPacket( const LLHost& host, const S3  static LLTrace::BlockTimerStatHandle FTM_PROCESS_MESSAGES("Process Messages");  // decode a given message -bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender ) +bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender, bool custom )  {      LL_RECORD_BLOCK_TIME(FTM_PROCESS_MESSAGES); @@ -591,6 +601,7 @@ bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender          }          else          { +            if (!custom)              LL_ERRS() << "Unknown block type" << LL_ENDL;              return false;          } @@ -637,6 +648,7 @@ bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender                      if ((decode_pos + data_size) > mReceiveSize)                      { +                        if (!custom)                          logRanOffEndOfPacket(sender, decode_pos, data_size);                          // default to 0 length variable blocks @@ -673,6 +685,7 @@ bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender                      // so, copy data pointer and set data size to fixed size                      if ((decode_pos + mvci.getSize()) > mReceiveSize)                      { +                        if (!custom)                          logRanOffEndOfPacket(sender, decode_pos, mvci.getSize());                          // default to 0s. @@ -697,10 +710,11 @@ bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender      if (mCurrentRMessageData->mMemberBlocks.empty()          && !mCurrentRMessageTemplate->mMemberBlocks.empty())      { -        LL_DEBUGS() << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << LL_ENDL; +        LL_WARNS() << "Empty message '" << mCurrentRMessageTemplate->mName << "' (no blocks)" << LL_ENDL;          return false;      } +    if (!custom)      {          static LLTimer decode_timer; @@ -753,11 +767,12 @@ bool LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender  bool LLTemplateMessageReader::validateMessage(const U8* buffer,                                                S32 buffer_size,                                                const LLHost& sender, -                                              bool trusted) +                                              bool trusted, +                                              bool custom)  {      mReceiveSize = buffer_size; -    bool valid = decodeTemplate(buffer, buffer_size, &mCurrentRMessageTemplate ); -    if(valid) +    BOOL valid = decodeTemplate(buffer, buffer_size, &mCurrentRMessageTemplate, custom ); +    if(valid && !custom)      {          mCurrentRMessageTemplate->mReceiveCount++;          //LL_DEBUGS() << "MessageRecvd:" @@ -828,3 +843,9 @@ void LLTemplateMessageReader::copyToBuilder(LLMessageBuilder& builder) const      }      builder.copyFromMessageData(*mCurrentRMessageData);  } + +LLMessageTemplate* LLTemplateMessageReader::getTemplate() +{ +    return mCurrentRMessageTemplate; +} + diff --git a/indra/llmessage/lltemplatemessagereader.h b/indra/llmessage/lltemplatemessagereader.h index 6f1977cf83..0f7160d328 100644 --- a/indra/llmessage/lltemplatemessagereader.h +++ b/indra/llmessage/lltemplatemessagereader.h @@ -99,25 +99,26 @@ public:      virtual void copyToBuilder(LLMessageBuilder&) const;      bool validateMessage(const U8* buffer, S32 buffer_size, -                         const LLHost& sender, bool trusted = false); +                         const LLHost& sender, bool trusted = false, bool custom = false);      bool readMessage(const U8* buffer, const LLHost& sender);      bool isTrusted() const;      bool isBanned(bool trusted_source) const;      bool isUdpBanned() const; +    bool decodeData(const U8* buffer, const LLHost& sender, bool custom = false ); +    LLMessageTemplate* getTemplate(); +  private:      void getData(const char *blockname, const char *varname, void *datap,                   S32 size = 0, S32 blocknum = 0, S32 max_size = S32_MAX);      bool decodeTemplate(const U8* buffer, S32 buffer_size,  // inputs -                        LLMessageTemplate** msg_template ); // outputs +                        LLMessageTemplate** msg_template, bool custom = false ); // outputs      void logRanOffEndOfPacket( const LLHost& host, const S32 where, const S32 wanted ); -    bool decodeData(const U8* buffer, const LLHost& sender ); -      S32 mReceiveSize;      LLMessageTemplate* mCurrentRMessageTemplate;      LLMsgData* mCurrentRMessageData; | 
