summaryrefslogtreecommitdiff
path: root/indra/llmessage
diff options
context:
space:
mode:
authorKelly Washington <kelly@lindenlab.com>2007-06-21 22:40:22 +0000
committerKelly Washington <kelly@lindenlab.com>2007-06-21 22:40:22 +0000
commite03bb0606a10f29c8b94909a713a5bb5c69e88b7 (patch)
tree6d8d07894579438c8cc70e08f5730c3c95dfe768 /indra/llmessage
parent2638f12f95eea692502836cf6548b4a0b234d009 (diff)
merge -r62831:64079 branches/maintenance to release
Diffstat (limited to 'indra/llmessage')
-rw-r--r--indra/llmessage/llblowfishcipher.cpp56
-rw-r--r--indra/llmessage/llcachename.cpp196
-rw-r--r--indra/llmessage/llcurl.cpp2
-rw-r--r--indra/llmessage/llhttpassetstorage.cpp3
-rw-r--r--indra/llmessage/llhttpnode.cpp2
-rw-r--r--indra/llmessage/lliohttpserver.cpp2
-rw-r--r--indra/llmessage/lliosocket.cpp2
-rw-r--r--indra/llmessage/llmessagethrottle.cpp2
-rw-r--r--indra/llmessage/llservicebuilder.cpp1
-rw-r--r--indra/llmessage/lltemplatemessagereader.cpp2
-rw-r--r--indra/llmessage/message.cpp16
-rw-r--r--indra/llmessage/net.cpp12
-rw-r--r--indra/llmessage/net.h2
13 files changed, 156 insertions, 142 deletions
diff --git a/indra/llmessage/llblowfishcipher.cpp b/indra/llmessage/llblowfishcipher.cpp
index d15e4fb69a..609c136d14 100644
--- a/indra/llmessage/llblowfishcipher.cpp
+++ b/indra/llmessage/llblowfishcipher.cpp
@@ -1,5 +1,5 @@
/**
- * @file llblowcipher.cpp
+ * @file llblowfishcipher.cpp
* @brief Wrapper around OpenSSL Blowfish encryption algorithm.
*
* We do not have OpenSSL headers or libraries on Windows, so this
@@ -65,33 +65,33 @@ U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len)
<< " iv_len " << iv_length
<< llendl;
- int output_len = 0;
- int temp_len = 0;
- if (!EVP_EncryptUpdate(&context,
- dst,
- &output_len,
- src,
- src_len))
- {
- llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl;
- goto ERROR;
- }
-
- // There may be some final data left to encrypt if the input is
- // not an exact multiple of the block size.
- if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
- {
- llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl;
- goto ERROR;
- }
- output_len += temp_len;
-
- EVP_CIPHER_CTX_cleanup(&context);
- return output_len;
-
-ERROR:
- EVP_CIPHER_CTX_cleanup(&context);
- return 0;
+ int output_len = 0;
+ int temp_len = 0;
+ if (!EVP_EncryptUpdate(&context,
+ dst,
+ &output_len,
+ src,
+ src_len))
+ {
+ llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl;
+ goto ERROR;
+ }
+
+ // There may be some final data left to encrypt if the input is
+ // not an exact multiple of the block size.
+ if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len))
+ {
+ llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl;
+ goto ERROR;
+ }
+ output_len += temp_len;
+
+ EVP_CIPHER_CTX_cleanup(&context);
+ return output_len;
+
+ERROR:
+ EVP_CIPHER_CTX_cleanup(&context);
+ return 0;
}
// virtual
diff --git a/indra/llmessage/llcachename.cpp b/indra/llmessage/llcachename.cpp
index 9c6e5e7f85..f1d2925026 100644
--- a/indra/llmessage/llcachename.cpp
+++ b/indra/llmessage/llcachename.cpp
@@ -46,132 +46,130 @@ LLCacheName* gCacheName = NULL;
/// class LLCacheNameEntry
/// ---------------------------------------------------------------------------
-namespace {
- class LLCacheNameEntry
- {
- public:
- LLCacheNameEntry();
+class LLCacheNameEntry
+{
+public:
+ LLCacheNameEntry();
- public:
- bool mIsGroup;
- U32 mCreateTime; // unix time_t
- char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
- char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
- char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
- };
+public:
+ bool mIsGroup;
+ U32 mCreateTime; // unix time_t
+ char mFirstName[DB_FIRST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
+ char mLastName[DB_LAST_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
+ char mGroupName[DB_GROUP_NAME_BUF_SIZE]; /*Flawfinder: ignore*/
+};
- LLCacheNameEntry::LLCacheNameEntry()
- {
- mFirstName[0] = '\0';
- mLastName[0] = '\0';
- mGroupName[0] = '\0';
- }
+LLCacheNameEntry::LLCacheNameEntry()
+{
+ mFirstName[0] = '\0';
+ mLastName[0] = '\0';
+ mGroupName[0] = '\0';
+}
- class PendingReply
- {
- public:
- LLUUID mID;
- LLCacheNameCallback mCallback;
- LLHost mHost;
- void* mData;
- PendingReply(const LLUUID& id, LLCacheNameCallback callback, void* data = NULL)
- : mID(id), mCallback(callback), mData(data)
- { }
+class PendingReply
+{
+public:
+ LLUUID mID;
+ LLCacheNameCallback mCallback;
+ LLHost mHost;
+ void* mData;
+ PendingReply(const LLUUID& id, LLCacheNameCallback callback, void* data = NULL)
+ : mID(id), mCallback(callback), mData(data)
+ { }
- PendingReply(const LLUUID& id, const LLHost& host)
- : mID(id), mCallback(0), mHost(host)
- { }
+ PendingReply(const LLUUID& id, const LLHost& host)
+ : mID(id), mCallback(0), mHost(host)
+ { }
- void done() { mID.setNull(); }
- bool isDone() const { return mID.isNull() != FALSE; }
- };
+ void done() { mID.setNull(); }
+ bool isDone() const { return mID.isNull() != FALSE; }
+};
- class ReplySender
- {
- public:
- ReplySender(LLMessageSystem* msg);
- ~ReplySender();
+class ReplySender
+{
+public:
+ ReplySender(LLMessageSystem* msg);
+ ~ReplySender();
- void send(const LLUUID& id,
- const LLCacheNameEntry& entry, const LLHost& host);
+ void send(const LLUUID& id,
+ const LLCacheNameEntry& entry, const LLHost& host);
- private:
- void flush();
+private:
+ void flush();
- LLMessageSystem* mMsg;
- bool mPending;
- bool mCurrIsGroup;
- LLHost mCurrHost;
- };
+ LLMessageSystem* mMsg;
+ bool mPending;
+ bool mCurrIsGroup;
+ LLHost mCurrHost;
+};
- ReplySender::ReplySender(LLMessageSystem* msg)
- : mMsg(msg), mPending(false)
- { }
+ReplySender::ReplySender(LLMessageSystem* msg)
+ : mMsg(msg), mPending(false)
+{ }
- ReplySender::~ReplySender()
- {
- flush();
- }
+ReplySender::~ReplySender()
+{
+ flush();
+}
- void ReplySender::send(const LLUUID& id,
- const LLCacheNameEntry& entry, const LLHost& host)
+void ReplySender::send(const LLUUID& id,
+ const LLCacheNameEntry& entry, const LLHost& host)
+{
+ if (mPending)
{
- if (mPending)
+ if (mCurrIsGroup != entry.mIsGroup
+ || mCurrHost != host)
{
- if (mCurrIsGroup != entry.mIsGroup
- || mCurrHost != host)
- {
- flush();
- }
+ flush();
}
+ }
- if (!mPending)
- {
- mPending = true;
- mCurrIsGroup = entry.mIsGroup;
- mCurrHost = host;
-
- if(mCurrIsGroup)
- mMsg->newMessageFast(_PREHASH_UUIDGroupNameReply);
- else
- mMsg->newMessageFast(_PREHASH_UUIDNameReply);
- }
+ if (!mPending)
+ {
+ mPending = true;
+ mCurrIsGroup = entry.mIsGroup;
+ mCurrHost = host;
- mMsg->nextBlockFast(_PREHASH_UUIDNameBlock);
- mMsg->addUUIDFast(_PREHASH_ID, id);
if(mCurrIsGroup)
- {
- mMsg->addStringFast(_PREHASH_GroupName, entry.mGroupName);
- }
+ mMsg->newMessageFast(_PREHASH_UUIDGroupNameReply);
else
- {
- mMsg->addStringFast(_PREHASH_FirstName, entry.mFirstName);
- mMsg->addStringFast(_PREHASH_LastName, entry.mLastName);
- }
+ mMsg->newMessageFast(_PREHASH_UUIDNameReply);
+ }
- if(mMsg->isSendFullFast(_PREHASH_UUIDNameBlock))
- {
- flush();
- }
+ mMsg->nextBlockFast(_PREHASH_UUIDNameBlock);
+ mMsg->addUUIDFast(_PREHASH_ID, id);
+ if(mCurrIsGroup)
+ {
+ mMsg->addStringFast(_PREHASH_GroupName, entry.mGroupName);
+ }
+ else
+ {
+ mMsg->addStringFast(_PREHASH_FirstName, entry.mFirstName);
+ mMsg->addStringFast(_PREHASH_LastName, entry.mLastName);
}
- void ReplySender::flush()
+ if(mMsg->isSendFullFast(_PREHASH_UUIDNameBlock))
{
- if (mPending)
- {
- mMsg->sendReliable(mCurrHost);
- mPending = false;
- }
+ flush();
}
+}
+void ReplySender::flush()
+{
+ if (mPending)
+ {
+ mMsg->sendReliable(mCurrHost);
+ mPending = false;
+ }
+}
- typedef std::set<LLUUID> AskQueue;
- typedef std::vector<PendingReply> ReplyQueue;
- typedef std::map<LLUUID,U32> PendingQueue;
- typedef std::map<LLUUID, LLCacheNameEntry*> Cache;
- typedef std::vector<LLCacheNameCallback> Observers;
-};
+
+typedef std::set<LLUUID> AskQueue;
+typedef std::vector<PendingReply> ReplyQueue;
+typedef std::map<LLUUID,U32> PendingQueue;
+typedef std::map<LLUUID, LLCacheNameEntry*> Cache;
+typedef std::vector<LLCacheNameCallback> Observers;
class LLCacheName::Impl
{
diff --git a/indra/llmessage/llcurl.cpp b/indra/llmessage/llcurl.cpp
index ffc15d45f7..bf3ea1cd6f 100644
--- a/indra/llmessage/llcurl.cpp
+++ b/indra/llmessage/llcurl.cpp
@@ -8,6 +8,8 @@
* $License$
*/
+#include "linden_common.h"
+
#include "llcurl.h"
#include <iomanip>
diff --git a/indra/llmessage/llhttpassetstorage.cpp b/indra/llmessage/llhttpassetstorage.cpp
index bca4e2364d..aa91ebcd49 100644
--- a/indra/llmessage/llhttpassetstorage.cpp
+++ b/indra/llmessage/llhttpassetstorage.cpp
@@ -819,11 +819,12 @@ void LLHTTPAssetStorage::checkForTimeouts()
if (curl_msg && curl_msg->msg == CURLMSG_DONE)
{
long curl_result = 0;
- S32 xfer_result = 0;
+ S32 xfer_result = LL_ERR_NOERR;
LLHTTPAssetRequest *req = NULL;
curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_PRIVATE, &req);
+ // TODO: Throw curl_result at all callbacks.
curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_HTTP_CODE, &curl_result);
if (RT_UPLOAD == req->mRequestType || RT_LOCALUPLOAD == req->mRequestType)
{
diff --git a/indra/llmessage/llhttpnode.cpp b/indra/llmessage/llhttpnode.cpp
index e7d441b22c..b1101f37ea 100644
--- a/indra/llmessage/llhttpnode.cpp
+++ b/indra/llmessage/llhttpnode.cpp
@@ -9,7 +9,7 @@
#include "linden_common.h"
#include "llhttpnode.h"
-#include "boost/tokenizer.hpp"
+#include <boost/tokenizer.hpp>
#include "llstl.h"
diff --git a/indra/llmessage/lliohttpserver.cpp b/indra/llmessage/lliohttpserver.cpp
index ca5fe849f7..07ca6a42a1 100644
--- a/indra/llmessage/lliohttpserver.cpp
+++ b/indra/llmessage/lliohttpserver.cpp
@@ -29,7 +29,7 @@
#include <sstream>
-#include "boost/tokenizer.hpp"
+#include <boost/tokenizer.hpp>
static const char HTTP_VERSION_STR[] = "HTTP/1.0";
static const std::string CONTEXT_REQUEST("request");
diff --git a/indra/llmessage/lliosocket.cpp b/indra/llmessage/lliosocket.cpp
index 6ccaa7fb1a..e96b23f134 100644
--- a/indra/llmessage/lliosocket.cpp
+++ b/indra/llmessage/lliosocket.cpp
@@ -421,6 +421,8 @@ LLIOPipe::EStatus LLIOSocketWriter::process_impl(
#if LL_WINDOWS
if (status == 730035)
break;
+#else
+ (void) status;
#endif
mLastWritten = segment.data() + len - 1;
diff --git a/indra/llmessage/llmessagethrottle.cpp b/indra/llmessage/llmessagethrottle.cpp
index 0cfaac3276..6a573381b3 100644
--- a/indra/llmessage/llmessagethrottle.cpp
+++ b/indra/llmessage/llmessagethrottle.cpp
@@ -6,6 +6,8 @@
* $License$
*/
+#include "linden_common.h"
+
#include "llhash.h"
#include "llmessagethrottle.h"
diff --git a/indra/llmessage/llservicebuilder.cpp b/indra/llmessage/llservicebuilder.cpp
index fbcf38ae35..8c34a506de 100644
--- a/indra/llmessage/llservicebuilder.cpp
+++ b/indra/llmessage/llservicebuilder.cpp
@@ -6,6 +6,7 @@
* $License$
*/
+#include "linden_common.h"
#include "llapp.h"
#include "llfile.h"
#include "llservicebuilder.h"
diff --git a/indra/llmessage/lltemplatemessagereader.cpp b/indra/llmessage/lltemplatemessagereader.cpp
index 892efb8697..bb3f4f4a15 100644
--- a/indra/llmessage/lltemplatemessagereader.cpp
+++ b/indra/llmessage/lltemplatemessagereader.cpp
@@ -594,7 +594,7 @@ BOOL LLTemplateMessageReader::decodeData(const U8* buffer, const LLHost& sender
tsize = tsizeh;
break;
case 4:
- htonmemcpy(&tsizeb, &buffer[decode_pos], MVT_U32, 4);
+ htonmemcpy(&tsize, &buffer[decode_pos], MVT_U32, 4);
break;
default:
llerrs << "Attempting to read variable field with unknown size of " << data_size << llendl;
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp
index c00a0fe154..456851a3ec 100644
--- a/indra/llmessage/message.cpp
+++ b/indra/llmessage/message.cpp
@@ -1321,7 +1321,7 @@ LLMessageSystem::~LLMessageSystem()
if (!mbError)
{
- end_net();
+ end_net(mSocket);
}
delete mTemplateMessageReader;
@@ -1335,6 +1335,9 @@ LLMessageSystem::~LLMessageSystem()
delete mLLSDMessageReader;
mLLSDMessageReader = NULL;
+ delete mLLSDMessageBuilder;
+ mLLSDMessageBuilder = NULL;
+
delete mPollInfop;
mPollInfop = NULL;
@@ -4144,11 +4147,13 @@ void LLMessageSystem::dumpPacketToLog()
char line_buffer[256]; /* Flawfinder: ignore */
S32 i;
S32 cur_line_pos = 0;
-
S32 cur_line = 0;
+
for (i = 0; i < mTrueReceiveSize; i++)
{
- snprintf(line_buffer + cur_line_pos*3, sizeof(line_buffer),"%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */
+ S32 offset = cur_line_pos * 3;
+ snprintf(line_buffer + offset, sizeof(line_buffer) - offset,
+ "%02x ", mTrueReceiveBuffer[i]); /* Flawfinder: ignore */
cur_line_pos++;
if (cur_line_pos >= 16)
{
@@ -4325,11 +4330,6 @@ std::string get_shared_secret()
typedef std::map<const char*, LLMessageBuilder*> BuilderMap;
-static void setBuilder(BuilderMap& map, const char* name, LLMessageBuilder* builder)
-{
- map[gMessageStringTable.getString(name)] = builder;
-}
-
void LLMessageSystem::newMessageFast(const char *name)
{
if(LLMessageConfig::isMessageBuiltTemplate(name))
diff --git a/indra/llmessage/net.cpp b/indra/llmessage/net.cpp
index 9e83ce1434..8cd7180f9a 100644
--- a/indra/llmessage/net.cpp
+++ b/indra/llmessage/net.cpp
@@ -269,8 +269,12 @@ S32 start_net(S32& socket_out, int& nPort)
return 0;
}
-void end_net()
+void end_net(S32& socket_out)
{
+ if (socket_out < 0)
+ {
+ closesocket(socket_out);
+ }
WSACleanup();
}
@@ -437,8 +441,12 @@ S32 start_net(S32& socket_out, int& nPort)
return 0;
}
-void end_net()
+void end_net(S32& socket_out)
{
+ if (socket_out < 0)
+ {
+ close(socket_out);
+ }
}
int receive_packet(int hSocket, char * receiveBuffer)
diff --git a/indra/llmessage/net.h b/indra/llmessage/net.h
index 1044807ba6..c544325dd2 100644
--- a/indra/llmessage/net.h
+++ b/indra/llmessage/net.h
@@ -20,7 +20,7 @@ class LLHost;
// Returns 0 on success, non-zero on error.
// Sets socket handler/descriptor, changes nPort if port requested is unavailable.
S32 start_net(S32& socket_out, int& nPort);
-void end_net();
+void end_net(S32& socket_out);
// returns size of packet or -1 in case of error
S32 receive_packet(int hSocket, char * receiveBuffer);