diff options
Diffstat (limited to 'linden/indra/llmessage')
49 files changed, 2815 insertions, 451 deletions
diff --git a/linden/indra/llmessage/files.lst b/linden/indra/llmessage/files.lst index b2f7d41..2ff3771 100644 --- a/linden/indra/llmessage/files.lst +++ b/linden/indra/llmessage/files.lst | |||
@@ -1,10 +1,12 @@ | |||
1 | llmessage/llassetstorage.cpp | 1 | llmessage/llassetstorage.cpp |
2 | llmessage/llblowfishcipher.cpp | ||
2 | llmessage/llbuffer.cpp | 3 | llmessage/llbuffer.cpp |
3 | llmessage/llbufferstream.cpp | 4 | llmessage/llbufferstream.cpp |
4 | llmessage/llcachename.cpp | 5 | llmessage/llcachename.cpp |
5 | llmessage/llchainio.cpp | 6 | llmessage/llchainio.cpp |
6 | llmessage/llcircuit.cpp | 7 | llmessage/llcircuit.cpp |
7 | llmessage/llclassifiedflags.cpp | 8 | llmessage/llclassifiedflags.cpp |
9 | llmessage/llcurl.cpp | ||
8 | llmessage/lldatapacker.cpp | 10 | llmessage/lldatapacker.cpp |
9 | llmessage/lldispatcher.cpp | 11 | llmessage/lldispatcher.cpp |
10 | llmessage/llfiltersd2xmlrpc.cpp | 12 | llmessage/llfiltersd2xmlrpc.cpp |
diff --git a/linden/indra/llmessage/llassetstorage.cpp b/linden/indra/llmessage/llassetstorage.cpp index eb26157..a8cd0e5 100644 --- a/linden/indra/llmessage/llassetstorage.cpp +++ b/linden/indra/llmessage/llassetstorage.cpp | |||
@@ -174,10 +174,40 @@ LLAssetRequest::LLAssetRequest(const LLUUID &uuid, const LLAssetType::EType type | |||
174 | mTime = LLMessageSystem::getMessageTimeSeconds(TRUE); | 174 | mTime = LLMessageSystem::getMessageTimeSeconds(TRUE); |
175 | } | 175 | } |
176 | 176 | ||
177 | // virtual | ||
177 | LLAssetRequest::~LLAssetRequest() | 178 | LLAssetRequest::~LLAssetRequest() |
178 | { | 179 | { |
179 | } | 180 | } |
180 | 181 | ||
182 | // virtual | ||
183 | LLSD LLAssetRequest::getTerseDetails() const | ||
184 | { | ||
185 | LLSD sd; | ||
186 | sd["asset_id"] = getUUID(); | ||
187 | sd["type_long"] = LLAssetType::lookupHumanReadable(getType()); | ||
188 | sd["type"] = LLAssetType::lookup(getType()); | ||
189 | sd["time"] = mTime; | ||
190 | time_t timestamp = (time_t) mTime; | ||
191 | std::ostringstream time_string; | ||
192 | time_string << ctime(×tamp); | ||
193 | sd["time_string"] = time_string.str(); | ||
194 | return sd; | ||
195 | } | ||
196 | |||
197 | // virtual | ||
198 | LLSD LLAssetRequest::getFullDetails() const | ||
199 | { | ||
200 | LLSD sd = getTerseDetails(); | ||
201 | sd["host"] = mHost.getIPandPort(); | ||
202 | sd["requesting_agent"] = mRequestingAgentID; | ||
203 | sd["is_temp"] = mIsTemp; | ||
204 | sd["is_local"] = mIsLocal; | ||
205 | sd["is_priority"] = mIsPriority; | ||
206 | sd["data_send_in_first_packet"] = mDataSentInFirstPacket; | ||
207 | sd["data_is_in_vfs"] = mDataIsInVFS; | ||
208 | |||
209 | return sd; | ||
210 | } | ||
181 | 211 | ||
182 | ///---------------------------------------------------------------------------- | 212 | ///---------------------------------------------------------------------------- |
183 | /// LLInvItemRequest | 213 | /// LLInvItemRequest |
@@ -298,47 +328,41 @@ void LLAssetStorage::checkForTimeouts() | |||
298 | 328 | ||
299 | void LLAssetStorage::_cleanupRequests(BOOL all, S32 error) | 329 | void LLAssetStorage::_cleanupRequests(BOOL all, S32 error) |
300 | { | 330 | { |
301 | const S32 NUM_QUEUES = 3; | ||
302 | F64 mt_secs = LLMessageSystem::getMessageTimeSeconds(); | 331 | F64 mt_secs = LLMessageSystem::getMessageTimeSeconds(); |
303 | 332 | ||
304 | std::list<LLAssetRequest*>* requests[NUM_QUEUES]; | 333 | request_list_t timed_out; |
305 | requests[0] = &mPendingDownloads; | 334 | S32 rt; |
306 | requests[1] = &mPendingUploads; | 335 | for (rt = 0; rt < RT_COUNT; rt++) |
307 | requests[2] = &mPendingLocalUploads; | ||
308 | static const char* REQUEST_TYPE[NUM_QUEUES] = { "download", "upload", "localuploads"}; | ||
309 | |||
310 | std::list<LLAssetRequest*> timed_out; | ||
311 | |||
312 | for (S32 ii = 0; ii < NUM_QUEUES; ++ii) | ||
313 | { | 336 | { |
314 | for (std::list<LLAssetRequest*>::iterator iter = requests[ii]->begin(); | 337 | request_list_t* requests = getRequestList((ERequestType)rt); |
315 | iter != requests[ii]->end(); ) | 338 | for (request_list_t::iterator iter = requests->begin(); |
339 | iter != requests->end(); ) | ||
316 | { | 340 | { |
317 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 341 | request_list_t::iterator curiter = iter++; |
318 | LLAssetRequest* tmp = *curiter; | 342 | LLAssetRequest* tmp = *curiter; |
319 | // if all is true, we want to clean up everything | 343 | // if all is true, we want to clean up everything |
320 | // otherwise just check for timed out requests | 344 | // otherwise just check for timed out requests |
321 | // EXCEPT for upload timeouts | 345 | // EXCEPT for upload timeouts |
322 | if (all | 346 | if (all |
323 | || ((0 == ii) | 347 | || ((RT_DOWNLOAD == rt) |
324 | && LL_ASSET_STORAGE_TIMEOUT < (mt_secs - tmp->mTime))) | 348 | && LL_ASSET_STORAGE_TIMEOUT < (mt_secs - tmp->mTime))) |
325 | { | 349 | { |
326 | llwarns << "Asset " << REQUEST_TYPE[ii] << " request " | 350 | llwarns << "Asset " << getRequestName((ERequestType)rt) << " request " |
327 | << (all ? "aborted" : "timed out") << " for " | 351 | << (all ? "aborted" : "timed out") << " for " |
328 | << tmp->getUUID() << "." | 352 | << tmp->getUUID() << "." |
329 | << LLAssetType::lookup(tmp->getType()) << llendl; | 353 | << LLAssetType::lookup(tmp->getType()) << llendl; |
330 | 354 | ||
331 | timed_out.push_front(tmp); | 355 | timed_out.push_front(tmp); |
332 | iter = requests[ii]->erase(curiter); | 356 | iter = requests->erase(curiter); |
333 | } | 357 | } |
334 | } | 358 | } |
335 | } | 359 | } |
336 | 360 | ||
337 | LLAssetInfo info; | 361 | LLAssetInfo info; |
338 | for (std::list<LLAssetRequest*>::iterator iter = timed_out.begin(); | 362 | for (request_list_t::iterator iter = timed_out.begin(); |
339 | iter != timed_out.end(); ) | 363 | iter != timed_out.end(); ) |
340 | { | 364 | { |
341 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 365 | request_list_t::iterator curiter = iter++; |
342 | LLAssetRequest* tmp = *curiter; | 366 | LLAssetRequest* tmp = *curiter; |
343 | if (tmp->mUpCallback) | 367 | if (tmp->mUpCallback) |
344 | { | 368 | { |
@@ -401,7 +425,7 @@ void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, vo | |||
401 | BOOL duplicate = FALSE; | 425 | BOOL duplicate = FALSE; |
402 | 426 | ||
403 | // check to see if there's a pending download of this uuid already | 427 | // check to see if there's a pending download of this uuid already |
404 | for (std::list<LLAssetRequest*>::iterator iter = mPendingDownloads.begin(); | 428 | for (request_list_t::iterator iter = mPendingDownloads.begin(); |
405 | iter != mPendingDownloads.end(); ++iter ) | 429 | iter != mPendingDownloads.end(); ++iter ) |
406 | { | 430 | { |
407 | LLAssetRequest *tmp = *iter; | 431 | LLAssetRequest *tmp = *iter; |
@@ -523,11 +547,11 @@ void LLAssetStorage::downloadCompleteCallback( | |||
523 | // find and callback ALL pending requests for this UUID | 547 | // find and callback ALL pending requests for this UUID |
524 | // SJB: We process the callbacks in reverse order, I do not know if this is important, | 548 | // SJB: We process the callbacks in reverse order, I do not know if this is important, |
525 | // but I didn't want to mess with it. | 549 | // but I didn't want to mess with it. |
526 | std::list<LLAssetRequest*> requests; | 550 | request_list_t requests; |
527 | for (std::list<LLAssetRequest*>::iterator iter = gAssetStorage->mPendingDownloads.begin(); | 551 | for (request_list_t::iterator iter = gAssetStorage->mPendingDownloads.begin(); |
528 | iter != gAssetStorage->mPendingDownloads.end(); ) | 552 | iter != gAssetStorage->mPendingDownloads.end(); ) |
529 | { | 553 | { |
530 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 554 | request_list_t::iterator curiter = iter++; |
531 | LLAssetRequest* tmp = *curiter; | 555 | LLAssetRequest* tmp = *curiter; |
532 | if ((tmp->getUUID() == req->getUUID()) && (tmp->getType()== req->getType())) | 556 | if ((tmp->getUUID() == req->getUUID()) && (tmp->getType()== req->getType())) |
533 | { | 557 | { |
@@ -535,10 +559,10 @@ void LLAssetStorage::downloadCompleteCallback( | |||
535 | iter = gAssetStorage->mPendingDownloads.erase(curiter); | 559 | iter = gAssetStorage->mPendingDownloads.erase(curiter); |
536 | } | 560 | } |
537 | } | 561 | } |
538 | for (std::list<LLAssetRequest*>::iterator iter = requests.begin(); | 562 | for (request_list_t::iterator iter = requests.begin(); |
539 | iter != requests.end(); ) | 563 | iter != requests.end(); ) |
540 | { | 564 | { |
541 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 565 | request_list_t::iterator curiter = iter++; |
542 | LLAssetRequest* tmp = *curiter; | 566 | LLAssetRequest* tmp = *curiter; |
543 | if (tmp->mDownCallback) | 567 | if (tmp->mDownCallback) |
544 | { | 568 | { |
@@ -896,11 +920,11 @@ void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType | |||
896 | { | 920 | { |
897 | // SJB: We process the callbacks in reverse order, I do not know if this is important, | 921 | // SJB: We process the callbacks in reverse order, I do not know if this is important, |
898 | // but I didn't want to mess with it. | 922 | // but I didn't want to mess with it. |
899 | std::list<LLAssetRequest*> requests; | 923 | request_list_t requests; |
900 | for (std::list<LLAssetRequest*>::iterator iter = mPendingUploads.begin(); | 924 | for (request_list_t::iterator iter = mPendingUploads.begin(); |
901 | iter != mPendingUploads.end(); ) | 925 | iter != mPendingUploads.end(); ) |
902 | { | 926 | { |
903 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 927 | request_list_t::iterator curiter = iter++; |
904 | LLAssetRequest* req = *curiter; | 928 | LLAssetRequest* req = *curiter; |
905 | if ((req->getUUID() == uuid) && (req->getType() == asset_type)) | 929 | if ((req->getUUID() == uuid) && (req->getType() == asset_type)) |
906 | { | 930 | { |
@@ -908,10 +932,10 @@ void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType | |||
908 | iter = mPendingUploads.erase(curiter); | 932 | iter = mPendingUploads.erase(curiter); |
909 | } | 933 | } |
910 | } | 934 | } |
911 | for (std::list<LLAssetRequest*>::iterator iter = mPendingLocalUploads.begin(); | 935 | for (request_list_t::iterator iter = mPendingLocalUploads.begin(); |
912 | iter != mPendingLocalUploads.end(); ) | 936 | iter != mPendingLocalUploads.end(); ) |
913 | { | 937 | { |
914 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 938 | request_list_t::iterator curiter = iter++; |
915 | LLAssetRequest* req = *curiter; | 939 | LLAssetRequest* req = *curiter; |
916 | if ((req->getUUID() == uuid) && (req->getType() == asset_type)) | 940 | if ((req->getUUID() == uuid) && (req->getType() == asset_type)) |
917 | { | 941 | { |
@@ -919,10 +943,10 @@ void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType | |||
919 | iter = mPendingLocalUploads.erase(curiter); | 943 | iter = mPendingLocalUploads.erase(curiter); |
920 | } | 944 | } |
921 | } | 945 | } |
922 | for (std::list<LLAssetRequest*>::iterator iter = requests.begin(); | 946 | for (request_list_t::iterator iter = requests.begin(); |
923 | iter != requests.end(); ) | 947 | iter != requests.end(); ) |
924 | { | 948 | { |
925 | std::list<LLAssetRequest*>::iterator curiter = iter++; | 949 | request_list_t::iterator curiter = iter++; |
926 | LLAssetRequest* req = *curiter; | 950 | LLAssetRequest* req = *curiter; |
927 | if (req->mUpCallback) | 951 | if (req->mUpCallback) |
928 | { | 952 | { |
@@ -932,45 +956,239 @@ void LLAssetStorage::_callUploadCallbacks(const LLUUID &uuid, LLAssetType::EType | |||
932 | } | 956 | } |
933 | } | 957 | } |
934 | 958 | ||
959 | LLAssetStorage::request_list_t* LLAssetStorage::getRequestList(LLAssetStorage::ERequestType rt) | ||
960 | { | ||
961 | switch (rt) | ||
962 | { | ||
963 | case RT_DOWNLOAD: | ||
964 | return &mPendingDownloads; | ||
965 | case RT_UPLOAD: | ||
966 | return &mPendingUploads; | ||
967 | case RT_LOCALUPLOAD: | ||
968 | return &mPendingLocalUploads; | ||
969 | default: | ||
970 | llwarns << "Unable to find request list for request type '" << rt << "'" << llendl; | ||
971 | return NULL; | ||
972 | } | ||
973 | } | ||
974 | |||
975 | const LLAssetStorage::request_list_t* LLAssetStorage::getRequestList(LLAssetStorage::ERequestType rt) const | ||
976 | { | ||
977 | switch (rt) | ||
978 | { | ||
979 | case RT_DOWNLOAD: | ||
980 | return &mPendingDownloads; | ||
981 | case RT_UPLOAD: | ||
982 | return &mPendingUploads; | ||
983 | case RT_LOCALUPLOAD: | ||
984 | return &mPendingLocalUploads; | ||
985 | default: | ||
986 | llwarns << "Unable to find request list for request type '" << rt << "'" << llendl; | ||
987 | return NULL; | ||
988 | } | ||
989 | } | ||
990 | |||
991 | // static | ||
992 | std::string LLAssetStorage::getRequestName(LLAssetStorage::ERequestType rt) | ||
993 | { | ||
994 | switch (rt) | ||
995 | { | ||
996 | case RT_DOWNLOAD: | ||
997 | return "download"; | ||
998 | case RT_UPLOAD: | ||
999 | return "upload"; | ||
1000 | case RT_LOCALUPLOAD: | ||
1001 | return "localupload"; | ||
1002 | default: | ||
1003 | llwarns << "Unable to find request name for request type '" << rt << "'" << llendl; | ||
1004 | return ""; | ||
1005 | } | ||
1006 | } | ||
1007 | |||
1008 | S32 LLAssetStorage::getNumPending(LLAssetStorage::ERequestType rt) const | ||
1009 | { | ||
1010 | const request_list_t* requests = getRequestList(rt); | ||
1011 | S32 num_pending = -1; | ||
1012 | if (requests) | ||
1013 | { | ||
1014 | num_pending = requests->size(); | ||
1015 | } | ||
1016 | return num_pending; | ||
1017 | } | ||
935 | 1018 | ||
936 | S32 LLAssetStorage::getNumPendingDownloads() const | 1019 | S32 LLAssetStorage::getNumPendingDownloads() const |
937 | { | 1020 | { |
938 | return mPendingDownloads.size(); | 1021 | return getNumPending(RT_DOWNLOAD); |
939 | } | 1022 | } |
940 | 1023 | ||
941 | S32 LLAssetStorage::getNumPendingUploads() const | 1024 | S32 LLAssetStorage::getNumPendingUploads() const |
942 | { | 1025 | { |
943 | return mPendingUploads.size(); | 1026 | return getNumPending(RT_UPLOAD); |
944 | } | 1027 | } |
945 | 1028 | ||
946 | S32 LLAssetStorage::getNumPendingLocalUploads() | 1029 | S32 LLAssetStorage::getNumPendingLocalUploads() |
947 | { | 1030 | { |
948 | return mPendingLocalUploads.size(); | 1031 | return getNumPending(RT_LOCALUPLOAD); |
1032 | } | ||
1033 | |||
1034 | // virtual | ||
1035 | LLSD LLAssetStorage::getPendingDetails(LLAssetStorage::ERequestType rt, | ||
1036 | LLAssetType::EType asset_type, | ||
1037 | const std::string& detail_prefix) const | ||
1038 | { | ||
1039 | const request_list_t* requests = getRequestList(rt); | ||
1040 | LLSD sd; | ||
1041 | sd["requests"] = getPendingDetails(requests, asset_type, detail_prefix); | ||
1042 | return sd; | ||
1043 | } | ||
1044 | |||
1045 | // virtual | ||
1046 | LLSD LLAssetStorage::getPendingDetails(const LLAssetStorage::request_list_t* requests, | ||
1047 | LLAssetType::EType asset_type, | ||
1048 | const std::string& detail_prefix) const | ||
1049 | { | ||
1050 | LLSD details; | ||
1051 | if (requests) | ||
1052 | { | ||
1053 | request_list_t::const_iterator it = requests->begin(); | ||
1054 | request_list_t::const_iterator end = requests->end(); | ||
1055 | for ( ; it != end; ++it) | ||
1056 | { | ||
1057 | LLAssetRequest* req = *it; | ||
1058 | if ( (LLAssetType::AT_NONE == asset_type) | ||
1059 | || (req->getType() == asset_type) ) | ||
1060 | { | ||
1061 | LLSD row = req->getTerseDetails(); | ||
1062 | |||
1063 | std::ostringstream detail; | ||
1064 | detail << detail_prefix << "/" << LLAssetType::lookup(req->getType()) | ||
1065 | << "/" << req->getUUID(); | ||
1066 | row["detail"] = LLURI(detail.str()); | ||
1067 | |||
1068 | details.append(row); | ||
1069 | } | ||
1070 | } | ||
1071 | } | ||
1072 | return details; | ||
1073 | } | ||
1074 | |||
1075 | |||
1076 | // static | ||
1077 | const LLAssetRequest* LLAssetStorage::findRequest(const LLAssetStorage::request_list_t* requests, | ||
1078 | LLAssetType::EType asset_type, | ||
1079 | const LLUUID& asset_id) | ||
1080 | { | ||
1081 | if (requests) | ||
1082 | { | ||
1083 | // Search the requests list for the asset. | ||
1084 | request_list_t::const_iterator iter = requests->begin(); | ||
1085 | request_list_t::const_iterator end = requests->end(); | ||
1086 | for (; iter != end; ++iter) | ||
1087 | { | ||
1088 | const LLAssetRequest* req = *iter; | ||
1089 | if (asset_type == req->getType() && | ||
1090 | asset_id == req->getUUID() ) | ||
1091 | { | ||
1092 | return req; | ||
1093 | } | ||
1094 | } | ||
1095 | } | ||
1096 | return NULL; | ||
949 | } | 1097 | } |
950 | 1098 | ||
951 | LLSD LLAssetStorage::getPendingTypes(const std::list<LLAssetRequest*>& requests) const | 1099 | // static |
1100 | LLAssetRequest* LLAssetStorage::findRequest(LLAssetStorage::request_list_t* requests, | ||
1101 | LLAssetType::EType asset_type, | ||
1102 | const LLUUID& asset_id) | ||
952 | { | 1103 | { |
953 | LLSD type_counts; | 1104 | if (requests) |
954 | std::list<LLAssetRequest*>::const_iterator it = requests.begin(); | ||
955 | std::list<LLAssetRequest*>::const_iterator end = requests.end(); | ||
956 | for ( ; it != end; ++it) | ||
957 | { | 1105 | { |
958 | LLAssetRequest* req = *it; | 1106 | // Search the requests list for the asset. |
1107 | request_list_t::iterator iter = requests->begin(); | ||
1108 | request_list_t::iterator end = requests->end(); | ||
1109 | for (; iter != end; ++iter) | ||
1110 | { | ||
1111 | LLAssetRequest* req = *iter; | ||
1112 | if (asset_type == req->getType() && | ||
1113 | asset_id == req->getUUID() ) | ||
1114 | { | ||
1115 | return req; | ||
1116 | } | ||
1117 | } | ||
1118 | } | ||
1119 | return NULL; | ||
1120 | } | ||
1121 | |||
959 | 1122 | ||
960 | const char* type_name = LLAssetType::lookupHumanReadable(req->getType()); | 1123 | // virtual |
961 | type_counts[type_name] = type_counts[type_name].asInteger() + 1; | 1124 | LLSD LLAssetStorage::getPendingRequest(LLAssetStorage::ERequestType rt, |
1125 | LLAssetType::EType asset_type, | ||
1126 | const LLUUID& asset_id) const | ||
1127 | { | ||
1128 | const request_list_t* requests = getRequestList(rt); | ||
1129 | return getPendingRequest(requests, asset_type, asset_id); | ||
1130 | } | ||
1131 | |||
1132 | // virtual | ||
1133 | LLSD LLAssetStorage::getPendingRequest(const LLAssetStorage::request_list_t* requests, | ||
1134 | LLAssetType::EType asset_type, | ||
1135 | const LLUUID& asset_id) const | ||
1136 | { | ||
1137 | LLSD sd; | ||
1138 | const LLAssetRequest* req = findRequest(requests, asset_type, asset_id); | ||
1139 | if (req) | ||
1140 | { | ||
1141 | sd = req->getFullDetails(); | ||
962 | } | 1142 | } |
963 | return type_counts; | 1143 | return sd; |
964 | } | 1144 | } |
965 | 1145 | ||
966 | LLSD LLAssetStorage::getPendingDownloadTypes() const | 1146 | // virtual |
1147 | bool LLAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt, | ||
1148 | LLAssetType::EType asset_type, | ||
1149 | const LLUUID& asset_id) | ||
967 | { | 1150 | { |
968 | return getPendingTypes(mPendingDownloads); | 1151 | request_list_t* requests = getRequestList(rt); |
1152 | if (deletePendingRequest(requests, asset_type, asset_id)) | ||
1153 | { | ||
1154 | llinfos << "Asset " << getRequestName(rt) << " request for " | ||
1155 | << asset_id << "." << LLAssetType::lookup(asset_type) | ||
1156 | << " removed from pending queue." << llendl; | ||
1157 | return true; | ||
1158 | } | ||
1159 | return false; | ||
969 | } | 1160 | } |
970 | 1161 | ||
971 | LLSD LLAssetStorage::getPendingUploadTypes() const | 1162 | // virtual |
1163 | bool LLAssetStorage::deletePendingRequest(LLAssetStorage::request_list_t* requests, | ||
1164 | LLAssetType::EType asset_type, | ||
1165 | const LLUUID& asset_id) | ||
972 | { | 1166 | { |
973 | return getPendingTypes(mPendingUploads); | 1167 | LLAssetRequest* req = findRequest(requests, asset_type, asset_id); |
1168 | if (req) | ||
1169 | { | ||
1170 | // Remove the request from this list. | ||
1171 | requests->remove(req); | ||
1172 | S32 error = LL_ERR_TCP_TIMEOUT; | ||
1173 | // Run callbacks. | ||
1174 | if (req->mUpCallback) | ||
1175 | { | ||
1176 | req->mUpCallback(req->getUUID(), req->mUserData, error); | ||
1177 | } | ||
1178 | if (req->mDownCallback) | ||
1179 | { | ||
1180 | req->mDownCallback(mVFS, req->getUUID(), req->getType(), req->mUserData, error); | ||
1181 | } | ||
1182 | if (req->mInfoCallback) | ||
1183 | { | ||
1184 | LLAssetInfo info; | ||
1185 | req->mInfoCallback(&info, req->mUserData, error); | ||
1186 | } | ||
1187 | delete req; | ||
1188 | return true; | ||
1189 | } | ||
1190 | |||
1191 | return false; | ||
974 | } | 1192 | } |
975 | 1193 | ||
976 | // static | 1194 | // static |
@@ -1015,7 +1233,7 @@ const char* LLAssetStorage::getErrorString(S32 status) | |||
1015 | void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32), void *user_data, BOOL is_priority) | 1233 | void LLAssetStorage::getAssetData(const LLUUID uuid, LLAssetType::EType type, void (*callback)(const char*, const LLUUID&, void *, S32), void *user_data, BOOL is_priority) |
1016 | { | 1234 | { |
1017 | // check for duplicates here, since we're about to fool the normal duplicate checker | 1235 | // check for duplicates here, since we're about to fool the normal duplicate checker |
1018 | for (std::list<LLAssetRequest*>::iterator iter = mPendingDownloads.begin(); | 1236 | for (request_list_t::iterator iter = mPendingDownloads.begin(); |
1019 | iter != mPendingDownloads.end(); ) | 1237 | iter != mPendingDownloads.end(); ) |
1020 | { | 1238 | { |
1021 | LLAssetRequest* tmp = *iter++; | 1239 | LLAssetRequest* tmp = *iter++; |
@@ -1056,12 +1274,12 @@ void LLAssetStorage::legacyGetDataCallback(LLVFS *vfs, const LLUUID &uuid, LLAss | |||
1056 | uuid.toString(uuid_str); | 1274 | uuid.toString(uuid_str); |
1057 | snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ | 1275 | snprintf(filename,sizeof(filename),"%s.%s",gDirUtilp->getExpandedFilename(LL_PATH_CACHE,uuid_str).c_str(),LLAssetType::lookup(type)); /* Flawfinder: ignore */ |
1058 | 1276 | ||
1059 | FILE *fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ | 1277 | FILE* fp = LLFile::fopen(filename, "wb"); /* Flawfinder: ignore */ |
1060 | if (fp) | 1278 | if (fp) |
1061 | { | 1279 | { |
1062 | const S32 buf_size = 65536; | 1280 | const S32 buf_size = 65536; |
1063 | U8 copy_buf[buf_size]; | 1281 | U8 copy_buf[buf_size]; |
1064 | while (file.read(copy_buf, buf_size)) | 1282 | while (file.read(copy_buf, buf_size)) /* Flawfinder: ignore */ |
1065 | { | 1283 | { |
1066 | if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1) | 1284 | if (fwrite(copy_buf, file.getLastBytesRead(), 1, fp) < 1) |
1067 | { | 1285 | { |
diff --git a/linden/indra/llmessage/llassetstorage.h b/linden/indra/llmessage/llassetstorage.h index deccad3..639ab59 100644 --- a/linden/indra/llmessage/llassetstorage.h +++ b/linden/indra/llmessage/llassetstorage.h | |||
@@ -109,6 +109,19 @@ public: | |||
109 | BOOL mDataSentInFirstPacket; | 109 | BOOL mDataSentInFirstPacket; |
110 | BOOL mDataIsInVFS; | 110 | BOOL mDataIsInVFS; |
111 | LLUUID mRequestingAgentID; // Only valid for uploads from an agent | 111 | LLUUID mRequestingAgentID; // Only valid for uploads from an agent |
112 | |||
113 | virtual LLSD getTerseDetails() const; | ||
114 | virtual LLSD getFullDetails() const; | ||
115 | }; | ||
116 | |||
117 | template <class T> | ||
118 | struct ll_asset_request_equal : public std::equal_to<T> | ||
119 | { | ||
120 | bool operator()(const T& x, const T& y) const | ||
121 | { | ||
122 | return ( x->getType() == y->getType() | ||
123 | && x->getUUID() == y->getUUID() ); | ||
124 | } | ||
112 | }; | 125 | }; |
113 | 126 | ||
114 | 127 | ||
@@ -184,6 +197,15 @@ public: | |||
184 | LLVFS *mVFS; | 197 | LLVFS *mVFS; |
185 | typedef void (*LLStoreAssetCallback)(const LLUUID &asset_id, void *user_data, S32 status); | 198 | typedef void (*LLStoreAssetCallback)(const LLUUID &asset_id, void *user_data, S32 status); |
186 | 199 | ||
200 | enum ERequestType | ||
201 | { | ||
202 | RT_INVALID = -1, | ||
203 | RT_DOWNLOAD = 0, | ||
204 | RT_UPLOAD = 1, | ||
205 | RT_LOCALUPLOAD = 2, | ||
206 | RT_COUNT = 3 | ||
207 | }; | ||
208 | |||
187 | protected: | 209 | protected: |
188 | BOOL mShutDown; | 210 | BOOL mShutDown; |
189 | LLHost mUpstreamHost; | 211 | LLHost mUpstreamHost; |
@@ -191,9 +213,11 @@ protected: | |||
191 | LLMessageSystem *mMessageSys; | 213 | LLMessageSystem *mMessageSys; |
192 | LLXferManager *mXferManager; | 214 | LLXferManager *mXferManager; |
193 | 215 | ||
194 | std::list<LLAssetRequest*> mPendingDownloads; | 216 | |
195 | std::list<LLAssetRequest*> mPendingUploads; | 217 | typedef std::list<LLAssetRequest*> request_list_t; |
196 | std::list<LLAssetRequest*> mPendingLocalUploads; | 218 | request_list_t mPendingDownloads; |
219 | request_list_t mPendingUploads; | ||
220 | request_list_t mPendingLocalUploads; | ||
197 | 221 | ||
198 | public: | 222 | public: |
199 | LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, | 223 | LLAssetStorage(LLMessageSystem *msg, LLXferManager *xfer, |
@@ -258,14 +282,48 @@ public: | |||
258 | const LLUUID &asset_id, LLAssetType::EType atype, | 282 | const LLUUID &asset_id, LLAssetType::EType atype, |
259 | LLGetAssetCallback cb, void *user_data, BOOL is_priority = FALSE); // Get a particular inventory item. | 283 | LLGetAssetCallback cb, void *user_data, BOOL is_priority = FALSE); // Get a particular inventory item. |
260 | 284 | ||
285 | protected: | ||
286 | virtual LLSD getPendingDetails(const request_list_t* requests, | ||
287 | LLAssetType::EType asset_type, | ||
288 | const std::string& detail_prefix) const; | ||
289 | |||
290 | virtual LLSD getPendingRequest(const request_list_t* requests, | ||
291 | LLAssetType::EType asset_type, | ||
292 | const LLUUID& asset_id) const; | ||
293 | |||
294 | virtual bool deletePendingRequest(request_list_t* requests, | ||
295 | LLAssetType::EType asset_type, | ||
296 | const LLUUID& asset_id); | ||
297 | |||
298 | public: | ||
299 | static const LLAssetRequest* findRequest(const request_list_t* requests, | ||
300 | LLAssetType::EType asset_type, | ||
301 | const LLUUID& asset_id); | ||
302 | static LLAssetRequest* findRequest(request_list_t* requests, | ||
303 | LLAssetType::EType asset_type, | ||
304 | const LLUUID& asset_id); | ||
305 | |||
306 | request_list_t* getRequestList(ERequestType rt); | ||
307 | const request_list_t* getRequestList(ERequestType rt) const; | ||
308 | static std::string getRequestName(ERequestType rt); | ||
261 | 309 | ||
262 | S32 getNumPendingDownloads() const; | 310 | S32 getNumPendingDownloads() const; |
263 | S32 getNumPendingUploads() const; | 311 | S32 getNumPendingUploads() const; |
264 | S32 getNumPendingLocalUploads(); | 312 | S32 getNumPendingLocalUploads(); |
313 | S32 getNumPending(ERequestType rt) const; | ||
314 | |||
315 | virtual LLSD getPendingDetails(ERequestType rt, | ||
316 | LLAssetType::EType asset_type, | ||
317 | const std::string& detail_prefix) const; | ||
318 | |||
319 | virtual LLSD getPendingRequest(ERequestType rt, | ||
320 | LLAssetType::EType asset_type, | ||
321 | const LLUUID& asset_id) const; | ||
322 | |||
323 | virtual bool deletePendingRequest(ERequestType rt, | ||
324 | LLAssetType::EType asset_type, | ||
325 | const LLUUID& asset_id); | ||
265 | 326 | ||
266 | // Returns a map from type to num pending, eg 'texture' => 5, 'object' => 10 | ||
267 | LLSD getPendingDownloadTypes() const; | ||
268 | LLSD getPendingUploadTypes() const; | ||
269 | 327 | ||
270 | // download process callbacks | 328 | // download process callbacks |
271 | static void downloadCompleteCallback( | 329 | static void downloadCompleteCallback( |
@@ -349,8 +407,6 @@ private: | |||
349 | LLXferManager *xfer, | 407 | LLXferManager *xfer, |
350 | LLVFS *vfs, | 408 | LLVFS *vfs, |
351 | const LLHost &upstream_host); | 409 | const LLHost &upstream_host); |
352 | LLSD getPendingTypes(const std::list<LLAssetRequest*>& requests) const; | ||
353 | |||
354 | }; | 410 | }; |
355 | 411 | ||
356 | //////////////////////////////////////////////////////////////////////// | 412 | //////////////////////////////////////////////////////////////////////// |
diff --git a/linden/indra/llmessage/llblowfishcipher.cpp b/linden/indra/llmessage/llblowfishcipher.cpp new file mode 100644 index 0000000..f9a68ab --- /dev/null +++ b/linden/indra/llmessage/llblowfishcipher.cpp | |||
@@ -0,0 +1,154 @@ | |||
1 | /** | ||
2 | * @file llblowcipher.cpp | ||
3 | * @brief Wrapper around OpenSSL Blowfish encryption algorithm. | ||
4 | * | ||
5 | * We do not have OpenSSL headers or libraries on Windows, so this | ||
6 | * class only works on Linux. | ||
7 | * | ||
8 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
9 | * | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlife.com/developers/opensource/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | */ | ||
30 | |||
31 | #include "linden_common.h" | ||
32 | |||
33 | #include "llblowfishcipher.h" | ||
34 | |||
35 | |||
36 | LLBlowfishCipher::LLBlowfishCipher(const U8* secret, size_t secret_size) | ||
37 | : LLCipher() | ||
38 | { | ||
39 | llassert(secret); | ||
40 | |||
41 | mSecretSize = secret_size; | ||
42 | mSecret = new U8[mSecretSize]; | ||
43 | memcpy(mSecret, secret, mSecretSize); | ||
44 | } | ||
45 | |||
46 | LLBlowfishCipher::~LLBlowfishCipher() | ||
47 | { | ||
48 | delete [] mSecret; | ||
49 | mSecret = NULL; | ||
50 | } | ||
51 | |||
52 | |||
53 | #if LL_LINUX | ||
54 | |||
55 | #include <openssl/evp.h> | ||
56 | |||
57 | // virtual | ||
58 | U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | ||
59 | { | ||
60 | if (!src || !src_len || !dst || !dst_len) return 0; | ||
61 | if (src_len > dst_len) return 0; | ||
62 | |||
63 | // OpenSSL uses "cipher contexts" to hold encryption parameters. | ||
64 | EVP_CIPHER_CTX context; | ||
65 | EVP_CIPHER_CTX_init(&context); | ||
66 | |||
67 | // We want a blowfish cyclic block chain cipher, but need to set | ||
68 | // the key length before we pass in a key, so call EncryptInit | ||
69 | // first with NULLs. | ||
70 | EVP_EncryptInit_ex(&context, EVP_bf_cbc(), NULL, NULL, NULL); | ||
71 | EVP_CIPHER_CTX_set_key_length(&context, (int)mSecretSize); | ||
72 | |||
73 | // Complete initialization. Per EVP_EncryptInit man page, the | ||
74 | // cipher pointer must be NULL. Apparently initial_vector must | ||
75 | // be 8 bytes for blowfish, as this is the block size. | ||
76 | unsigned char initial_vector[] = { 0, 0, 0, 0, 0, 0, 0, 0 }; | ||
77 | EVP_EncryptInit_ex(&context, NULL, NULL, mSecret, initial_vector); | ||
78 | |||
79 | int blocksize = EVP_CIPHER_CTX_block_size(&context); | ||
80 | int keylen = EVP_CIPHER_CTX_key_length(&context); | ||
81 | int iv_length = EVP_CIPHER_CTX_iv_length(&context); | ||
82 | lldebugs << "LLBlowfishCipher blocksize " << blocksize | ||
83 | << " keylen " << keylen | ||
84 | << " iv_len " << iv_length | ||
85 | << llendl; | ||
86 | |||
87 | int output_len = 0; | ||
88 | if (!EVP_EncryptUpdate(&context, | ||
89 | dst, | ||
90 | &output_len, | ||
91 | src, | ||
92 | src_len)) | ||
93 | { | ||
94 | llwarns << "LLBlowfishCipher::encrypt EVP_EncryptUpdate failure" << llendl; | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | // There may be some final data left to encrypt if the input is | ||
99 | // not an exact multiple of the block size. | ||
100 | int temp_len = 0; | ||
101 | if (!EVP_EncryptFinal_ex(&context, (unsigned char*)(dst + output_len), &temp_len)) | ||
102 | { | ||
103 | llwarns << "LLBlowfishCipher::encrypt EVP_EncryptFinal failure" << llendl; | ||
104 | return 0; | ||
105 | } | ||
106 | output_len += temp_len; | ||
107 | return output_len; | ||
108 | } | ||
109 | |||
110 | // virtual | ||
111 | U32 LLBlowfishCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | ||
112 | { | ||
113 | llerrs << "LLBlowfishCipher decrypt unsupported" << llendl; | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | // virtual | ||
118 | U32 LLBlowfishCipher::requiredEncryptionSpace(U32 len) const | ||
119 | { | ||
120 | // *HACK: We know blowfish uses an 8 byte block size. | ||
121 | // Oddly, sometimes EVP_Encrypt produces an extra block | ||
122 | // if the input is an exact multiple of the block size. | ||
123 | // So round up. | ||
124 | const U32 BLOCK_SIZE = 8; | ||
125 | len += BLOCK_SIZE; | ||
126 | len -= (len % BLOCK_SIZE); | ||
127 | return len; | ||
128 | } | ||
129 | |||
130 | #else // !LL_LINUX | ||
131 | |||
132 | // virtual | ||
133 | U32 LLBlowfishCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | ||
134 | { | ||
135 | llerrs << "LLBlowfishCipher only supported on Linux" << llendl; | ||
136 | return 0; | ||
137 | } | ||
138 | |||
139 | // virtual | ||
140 | U32 LLBlowfishCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | ||
141 | { | ||
142 | llerrs << "LLBlowfishCipher only supported on Linux" << llendl; | ||
143 | return 0; | ||
144 | } | ||
145 | |||
146 | // virtual | ||
147 | U32 LLBlowfishCipher::requiredEncryptionSpace(U32 len) const | ||
148 | { | ||
149 | llerrs << "LLBlowfishCipher only supported on Linux" << llendl; | ||
150 | return 0; | ||
151 | } | ||
152 | |||
153 | #endif | ||
154 | |||
diff --git a/linden/indra/llmessage/llblowfishcipher.h b/linden/indra/llmessage/llblowfishcipher.h new file mode 100644 index 0000000..2557598 --- /dev/null +++ b/linden/indra/llmessage/llblowfishcipher.h | |||
@@ -0,0 +1,58 @@ | |||
1 | /** | ||
2 | * @file llblowfishcipher.h | ||
3 | * @brief A symmetric block cipher, designed in 1993 by Bruce Schneier. | ||
4 | * We use it because it has an 8 byte block size, allowing encryption of | ||
5 | * two UUIDs and a timestamp (16x2 + 4 = 36 bytes) with only 40 bytes of | ||
6 | * output. AES has a block size of 32 bytes, so this would require 64 bytes. | ||
7 | * | ||
8 | * Copyright (c) 2007-2007, Linden Research, Inc. | ||
9 | * | ||
10 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
11 | * to you under the terms of the GNU General Public License, version 2.0 | ||
12 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
13 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
14 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
15 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlife.com/developers/opensource/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | */ | ||
30 | |||
31 | #ifndef LLBLOWFISHCIPHER_H | ||
32 | #define LLBLOWFISHCIPHER_H | ||
33 | |||
34 | #include "llcipher.h" | ||
35 | |||
36 | |||
37 | class LLBlowfishCipher : public LLCipher | ||
38 | { | ||
39 | public: | ||
40 | // Secret may be up to 56 bytes in length per Blowfish spec. | ||
41 | LLBlowfishCipher(const U8* secret, size_t secret_size); | ||
42 | virtual ~LLBlowfishCipher(); | ||
43 | |||
44 | // See llcipher.h for documentation. | ||
45 | /*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
46 | /*virtual*/ U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
47 | /*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const; | ||
48 | |||
49 | #ifdef _DEBUG | ||
50 | static BOOL testHarness(); | ||
51 | #endif | ||
52 | |||
53 | private: | ||
54 | U8* mSecret; | ||
55 | size_t mSecretSize; | ||
56 | }; | ||
57 | |||
58 | #endif // LL_LLCRYPTO_H | ||
diff --git a/linden/indra/llmessage/llbuffer.cpp b/linden/indra/llmessage/llbuffer.cpp index 07c730a..3dd34a0 100644 --- a/linden/indra/llmessage/llbuffer.cpp +++ b/linden/indra/llmessage/llbuffer.cpp | |||
@@ -109,7 +109,7 @@ LLHeapBuffer::LLHeapBuffer(const U8* src, S32 len) | |||
109 | allocate(len); | 109 | allocate(len); |
110 | if(mBuffer) | 110 | if(mBuffer) |
111 | { | 111 | { |
112 | memcpy(mBuffer, src, len); | 112 | memcpy(mBuffer, src, len); /*Flawfinder: ignore*/ |
113 | } | 113 | } |
114 | } | 114 | } |
115 | else | 115 | else |
@@ -735,7 +735,7 @@ bool LLBufferArray::copyIntoBuffers( | |||
735 | } | 735 | } |
736 | segments.push_back(segment); | 736 | segments.push_back(segment); |
737 | S32 bytes = llmin(segment.size(), len); | 737 | S32 bytes = llmin(segment.size(), len); |
738 | memcpy(segment.data(), src + copied, bytes); /* Flawfinder Ignore */ | 738 | memcpy(segment.data(), src + copied, bytes); /* Flawfinder: Ignore */ |
739 | copied += bytes; | 739 | copied += bytes; |
740 | len -= bytes; | 740 | len -= bytes; |
741 | if(0 == len) | 741 | if(0 == len) |
@@ -757,7 +757,7 @@ bool LLBufferArray::copyIntoBuffers( | |||
757 | return false; | 757 | return false; |
758 | } | 758 | } |
759 | segments.push_back(segment); | 759 | segments.push_back(segment); |
760 | memcpy(segment.data(), src + copied, segment.size()); | 760 | memcpy(segment.data(), src + copied, segment.size()); /*Flawfinder: ignore*/ |
761 | copied += segment.size(); | 761 | copied += segment.size(); |
762 | len -= segment.size(); | 762 | len -= segment.size(); |
763 | } | 763 | } |
diff --git a/linden/indra/llmessage/llcachename.cpp b/linden/indra/llmessage/llcachename.cpp index 3a92812..e92c72f 100644 --- a/linden/indra/llmessage/llcachename.cpp +++ b/linden/indra/llmessage/llcachename.cpp | |||
@@ -276,6 +276,40 @@ void LLCacheName::addObserver(LLCacheNameCallback callback) | |||
276 | impl.mObservers.push_back(callback); | 276 | impl.mObservers.push_back(callback); |
277 | } | 277 | } |
278 | 278 | ||
279 | void LLCacheName::removeObserver(LLCacheNameCallback callback) | ||
280 | { | ||
281 | Observers::iterator it = impl.mObservers.begin(); | ||
282 | Observers::iterator end = impl.mObservers.end(); | ||
283 | |||
284 | for ( ; it != end; ++it) | ||
285 | { | ||
286 | const LLCacheNameCallback& cb = (*it); | ||
287 | if (cb == callback) | ||
288 | { | ||
289 | impl.mObservers.erase(it); | ||
290 | return; | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | |||
295 | void LLCacheName::cancelCallback(const LLUUID& id, LLCacheNameCallback callback, void* user_data) | ||
296 | { | ||
297 | ReplyQueue::iterator it = impl.mReplyQueue.begin(); | ||
298 | ReplyQueue::iterator end = impl.mReplyQueue.end(); | ||
299 | |||
300 | for(; it != end; ++it) | ||
301 | { | ||
302 | const PendingReply& reply = (*it); | ||
303 | |||
304 | if ((callback == reply.mCallback) | ||
305 | && (id == reply.mID) | ||
306 | && (user_data == reply.mData) ) | ||
307 | { | ||
308 | impl.mReplyQueue.erase(it); | ||
309 | return; | ||
310 | } | ||
311 | } | ||
312 | } | ||
279 | 313 | ||
280 | void LLCacheName::importFile(FILE* fp) | 314 | void LLCacheName::importFile(FILE* fp) |
281 | { | 315 | { |
@@ -297,7 +331,10 @@ void LLCacheName::importFile(FILE* fp) | |||
297 | // *NOTE: This buffer size is hardcoded into sscanf() below | 331 | // *NOTE: This buffer size is hardcoded into sscanf() below |
298 | char version_string[BUFFER_SIZE]; /*Flawfinder: ignore*/ | 332 | char version_string[BUFFER_SIZE]; /*Flawfinder: ignore*/ |
299 | S32 version = 0; | 333 | S32 version = 0; |
300 | S32 match = sscanf(buffer, "%1023s %d", version_string, &version); | 334 | S32 match = sscanf( /* Flawfinder: ignore */ |
335 | buffer, | ||
336 | "%1023s %d", | ||
337 | version_string, &version); | ||
301 | if ( match != 2 | 338 | if ( match != 2 |
302 | || strcmp(version_string, "version") | 339 | || strcmp(version_string, "version") |
303 | || version != CN_FILE_VERSION) | 340 | || version != CN_FILE_VERSION) |
@@ -316,7 +353,7 @@ void LLCacheName::importFile(FILE* fp) | |||
316 | valid = fgets(buffer, BUFFER_SIZE, fp); | 353 | valid = fgets(buffer, BUFFER_SIZE, fp); |
317 | if (!valid) break; | 354 | if (!valid) break; |
318 | 355 | ||
319 | match = sscanf( | 356 | match = sscanf( /* Flawfinder: ignore */ |
320 | buffer, | 357 | buffer, |
321 | "%254s %u %254s %254s", | 358 | "%254s %u %254s %254s", |
322 | id_string, | 359 | id_string, |
@@ -395,7 +432,7 @@ BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) | |||
395 | { | 432 | { |
396 | // The function signature needs to change to pass in the | 433 | // The function signature needs to change to pass in the |
397 | // length of first and last. | 434 | // length of first and last. |
398 | strcpy(first, CN_NOBODY); | 435 | strcpy(first, CN_NOBODY); /*Flawfinder: ignore*/ |
399 | last[0] = '\0'; | 436 | last[0] = '\0'; |
400 | return FALSE; | 437 | return FALSE; |
401 | } | 438 | } |
@@ -405,8 +442,8 @@ BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) | |||
405 | { | 442 | { |
406 | // The function signature needs to change to pass in the | 443 | // The function signature needs to change to pass in the |
407 | // length of first and last. | 444 | // length of first and last. |
408 | strcpy(first, entry->mFirstName); | 445 | strcpy(first, entry->mFirstName); /*Flawfinder: ignore*/ |
409 | strcpy(last, entry->mLastName); | 446 | strcpy(last, entry->mLastName); /*Flawfinder: ignore*/ |
410 | return TRUE; | 447 | return TRUE; |
411 | } | 448 | } |
412 | else | 449 | else |
@@ -416,7 +453,7 @@ BOOL LLCacheName::getName(const LLUUID& id, char* first, char* last) | |||
416 | strcpy(first,(ll_frand() < HIPPO_PROBABILITY) | 453 | strcpy(first,(ll_frand() < HIPPO_PROBABILITY) |
417 | ? CN_HIPPOS | 454 | ? CN_HIPPOS |
418 | : CN_WAITING); | 455 | : CN_WAITING); |
419 | strcpy(last, ""); | 456 | strcpy(last, ""); /*Flawfinder: ignore*/ |
420 | 457 | ||
421 | impl.mAskNameQueue.push_back(id); | 458 | impl.mAskNameQueue.push_back(id); |
422 | return FALSE; | 459 | return FALSE; |
@@ -432,7 +469,7 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) | |||
432 | { | 469 | { |
433 | // The function signature needs to change to pass in the | 470 | // The function signature needs to change to pass in the |
434 | // length of first and last. | 471 | // length of first and last. |
435 | strcpy(group, CN_NONE); | 472 | strcpy(group, CN_NONE); /*Flawfinder: ignore*/ |
436 | return FALSE; | 473 | return FALSE; |
437 | } | 474 | } |
438 | 475 | ||
@@ -450,14 +487,14 @@ BOOL LLCacheName::getGroupName(const LLUUID& id, char* group) | |||
450 | { | 487 | { |
451 | // The function signature needs to change to pass in the length | 488 | // The function signature needs to change to pass in the length |
452 | // of group. | 489 | // of group. |
453 | strcpy(group, entry->mGroupName); | 490 | strcpy(group, entry->mGroupName); /*Flawfinder: ignore*/ |
454 | return TRUE; | 491 | return TRUE; |
455 | } | 492 | } |
456 | else | 493 | else |
457 | { | 494 | { |
458 | // The function signature needs to change to pass in the length | 495 | // The function signature needs to change to pass in the length |
459 | // of first and last. | 496 | // of first and last. |
460 | strcpy(group, CN_WAITING); | 497 | strcpy(group, CN_WAITING); /*Flawfinder: ignore*/ |
461 | 498 | ||
462 | impl.mAskGroupQueue.push_back(id); | 499 | impl.mAskGroupQueue.push_back(id); |
463 | return FALSE; | 500 | return FALSE; |
diff --git a/linden/indra/llmessage/llcachename.h b/linden/indra/llmessage/llcachename.h index 4dd42cb..9987f11 100644 --- a/linden/indra/llmessage/llcachename.h +++ b/linden/indra/llmessage/llcachename.h | |||
@@ -60,6 +60,8 @@ public: | |||
60 | void addObserver(LLCacheNameCallback callback); | 60 | void addObserver(LLCacheNameCallback callback); |
61 | void removeObserver(LLCacheNameCallback callback); | 61 | void removeObserver(LLCacheNameCallback callback); |
62 | 62 | ||
63 | void cancelCallback(const LLUUID& id, LLCacheNameCallback callback, void* user_data = NULL); | ||
64 | |||
63 | // storing cache on disk; for viewer, in name.cache | 65 | // storing cache on disk; for viewer, in name.cache |
64 | void importFile(FILE* fp); | 66 | void importFile(FILE* fp); |
65 | void exportFile(FILE* fp); | 67 | void exportFile(FILE* fp); |
diff --git a/linden/indra/llmessage/llcipher.h b/linden/indra/llmessage/llcipher.h new file mode 100644 index 0000000..c1f88ff --- /dev/null +++ b/linden/indra/llmessage/llcipher.h | |||
@@ -0,0 +1,57 @@ | |||
1 | /** | ||
2 | * @file llcipher.h | ||
3 | * @brief Abstract base class for encryption ciphers. | ||
4 | * | ||
5 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
6 | * | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
8 | * to you under the terms of the GNU General Public License, version 2.0 | ||
9 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
10 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
11 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
12 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
13 | * | ||
14 | * There are special exceptions to the terms and conditions of the GPL as | ||
15 | * it is applied to this Source Code. View the full text of the exception | ||
16 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
17 | * online at http://secondlife.com/developers/opensource/flossexception | ||
18 | * | ||
19 | * By copying, modifying or distributing this software, you acknowledge | ||
20 | * that you have read and understood your obligations described above, | ||
21 | * and agree to abide by those obligations. | ||
22 | * | ||
23 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
24 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
25 | * COMPLETENESS OR PERFORMANCE. | ||
26 | */ | ||
27 | |||
28 | #ifndef LLCIPHER_H | ||
29 | #define LLCIPHER_H | ||
30 | |||
31 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
32 | // Class LLCipher | ||
33 | // | ||
34 | // Abstract base class for a cipher object. | ||
35 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
36 | |||
37 | class LLCipher | ||
38 | { | ||
39 | public: | ||
40 | virtual ~LLCipher() {} | ||
41 | |||
42 | // encrypt src and place result into dst. returns TRUE if | ||
43 | // Returns number of bytes written into dst, or 0 on error. | ||
44 | virtual U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
45 | |||
46 | // decrypt src and place result into dst. | ||
47 | // Returns number of bytes written into dst, or 0 on error. | ||
48 | virtual U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
49 | |||
50 | // returns the minimum amount of space required to encrypt for a | ||
51 | // unencrypted source buffer of length len. | ||
52 | // *NOTE: This is estimated space and you should check the return value | ||
53 | // of the encrypt function. | ||
54 | virtual U32 requiredEncryptionSpace(U32 src_len) const = 0 ; | ||
55 | }; | ||
56 | |||
57 | #endif | ||
diff --git a/linden/indra/llmessage/llcurl.cpp b/linden/indra/llmessage/llcurl.cpp new file mode 100644 index 0000000..886697e --- /dev/null +++ b/linden/indra/llmessage/llcurl.cpp | |||
@@ -0,0 +1,343 @@ | |||
1 | /* | ||
2 | * llcurl.cpp | ||
3 | * MacTester | ||
4 | * | ||
5 | * Created by Zero Linden on 10/15/06. | ||
6 | * Copyright 2006 __MyCompanyName__. All rights reserved. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #include "llcurl.h" | ||
11 | |||
12 | #include <iomanip> | ||
13 | |||
14 | #include "llsdserialize.h" | ||
15 | |||
16 | ////////////////////////////////////////////////////////////////////////////// | ||
17 | /* | ||
18 | The trick to getting curl to do keep-alives is to reuse the | ||
19 | same easy handle for the requests. It appears that curl | ||
20 | keeps a pool of connections alive for each easy handle, but | ||
21 | doesn't share them between easy handles. Therefore it is | ||
22 | important to keep a pool of easy handles and reuse them, | ||
23 | rather than create and destroy them with each request. This | ||
24 | code does this. | ||
25 | |||
26 | Furthermore, it would behoove us to keep track of which | ||
27 | hosts an easy handle was used for and pick an easy handle | ||
28 | that matches the next request. This code does not current | ||
29 | do this. | ||
30 | */ | ||
31 | |||
32 | using namespace std; | ||
33 | |||
34 | LLCurl::Responder::Responder() | ||
35 | : mReferenceCount(0) | ||
36 | { | ||
37 | } | ||
38 | LLCurl::Responder::~Responder() | ||
39 | { | ||
40 | } | ||
41 | |||
42 | // virtual | ||
43 | void LLCurl::Responder::error(U32 status, const std::stringstream& content) | ||
44 | { | ||
45 | llinfos << "LLCurl::Responder::error " << status << ": " << content.str() << llendl; | ||
46 | } | ||
47 | |||
48 | // virtual | ||
49 | void LLCurl::Responder::result(const std::stringstream& content) | ||
50 | { | ||
51 | } | ||
52 | |||
53 | // virtual | ||
54 | void LLCurl::Responder::completed(U32 status, const std::stringstream& content) | ||
55 | { | ||
56 | if (200 <= status && status < 300) | ||
57 | { | ||
58 | result(content); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | error(status, content); | ||
63 | } | ||
64 | } | ||
65 | |||
66 | |||
67 | namespace boost | ||
68 | { | ||
69 | void intrusive_ptr_add_ref(LLCurl::Responder* p) | ||
70 | { | ||
71 | ++p->mReferenceCount; | ||
72 | } | ||
73 | |||
74 | void intrusive_ptr_release(LLCurl::Responder* p) | ||
75 | { | ||
76 | if(0 == --p->mReferenceCount) | ||
77 | { | ||
78 | delete p; | ||
79 | } | ||
80 | } | ||
81 | }; | ||
82 | |||
83 | ////////////////////////////////////////////////////////////////////////////// | ||
84 | |||
85 | size_t | ||
86 | curlOutputCallback(void* data, size_t size, size_t nmemb, void* user_data) | ||
87 | { | ||
88 | stringstream& output = *(stringstream*)user_data; | ||
89 | |||
90 | size_t n = size * nmemb; | ||
91 | output.write((const char*)data, n); | ||
92 | if (!((istream&)output).good()) { | ||
93 | std::cerr << "WHAT!?!?!? istream side bad" << std::endl; | ||
94 | } | ||
95 | if (!((ostream&)output).good()) { | ||
96 | std::cerr << "WHAT!?!?!? ostream side bad" << std::endl; | ||
97 | } | ||
98 | |||
99 | return n; | ||
100 | } | ||
101 | |||
102 | // Only used if request contained a body (post or put), Not currently implemented. | ||
103 | // size_t | ||
104 | // curlRequestCallback(void* data, size_t size, size_t nmemb, void* user_data) | ||
105 | // { | ||
106 | // stringstream& request = *(stringstream*)user_data; | ||
107 | |||
108 | // size_t n = size * nmemb; | ||
109 | // request.read((char*)data, n); | ||
110 | // return request.gcount(); | ||
111 | // } | ||
112 | |||
113 | |||
114 | |||
115 | |||
116 | |||
117 | LLCurl::Easy::Easy() | ||
118 | { | ||
119 | mHeaders = 0; | ||
120 | mHeaders = curl_slist_append(mHeaders, "Connection: keep-alive"); | ||
121 | mHeaders = curl_slist_append(mHeaders, "Keep-alive: 300"); | ||
122 | mHeaders = curl_slist_append(mHeaders, "Content-Type: application/xml"); | ||
123 | // FIXME: shouldn't be there for GET/DELETE | ||
124 | // FIXME: should have ACCEPT headers | ||
125 | |||
126 | mHandle = curl_easy_init(); | ||
127 | } | ||
128 | |||
129 | LLCurl::Easy::~Easy() | ||
130 | { | ||
131 | curl_easy_cleanup(mHandle); | ||
132 | curl_slist_free_all(mHeaders); | ||
133 | } | ||
134 | |||
135 | void | ||
136 | LLCurl::Easy::get(const string& url, ResponderPtr responder) | ||
137 | { | ||
138 | prep(url, responder); | ||
139 | curl_easy_setopt(mHandle, CURLOPT_HTTPGET, 1); | ||
140 | } | ||
141 | |||
142 | void | ||
143 | LLCurl::Easy::getByteRange(const string& url, S32 offset, S32 length, ResponderPtr responder) | ||
144 | { | ||
145 | mRange = llformat("Range: bytes=%d-%d", offset,offset+length-1); | ||
146 | mHeaders = curl_slist_append(mHeaders, mRange.c_str()); | ||
147 | prep(url, responder); | ||
148 | curl_easy_setopt(mHandle, CURLOPT_HTTPGET, 1); | ||
149 | } | ||
150 | |||
151 | void | ||
152 | LLCurl::Easy::perform() | ||
153 | { | ||
154 | report(curl_easy_perform(mHandle)); | ||
155 | } | ||
156 | |||
157 | void | ||
158 | LLCurl::Easy::prep(const std::string& url, ResponderPtr responder) | ||
159 | { | ||
160 | #if !LL_DARWIN | ||
161 | curl_easy_reset(mHandle); // SJB: doesn't exisit on OSX 10.3.9 | ||
162 | #else | ||
163 | // SJB: equivalent? fast? | ||
164 | curl_easy_cleanup(mHandle); | ||
165 | mHandle = curl_easy_init(); | ||
166 | #endif | ||
167 | |||
168 | curl_easy_setopt(mHandle, CURLOPT_PRIVATE, this); | ||
169 | |||
170 | // curl_easy_setopt(mHandle, CURLOPT_VERBOSE, 1); // usefull for debugging | ||
171 | curl_easy_setopt(mHandle, CURLOPT_NOSIGNAL, 1); | ||
172 | curl_easy_setopt(mHandle, CURLOPT_WRITEFUNCTION, &curlOutputCallback); | ||
173 | curl_easy_setopt(mHandle, CURLOPT_WRITEDATA, &mOutput); | ||
174 | #if 1 // For debug | ||
175 | curl_easy_setopt(mHandle, CURLOPT_HEADERFUNCTION, &curlOutputCallback); | ||
176 | curl_easy_setopt(mHandle, CURLOPT_HEADERDATA, &mHeaderOutput); | ||
177 | #endif | ||
178 | curl_easy_setopt(mHandle, CURLOPT_ERRORBUFFER, &mErrorBuffer); | ||
179 | curl_easy_setopt(mHandle, CURLOPT_ENCODING, ""); | ||
180 | curl_easy_setopt(mHandle, CURLOPT_SSL_VERIFYPEER, false); | ||
181 | curl_easy_setopt(mHandle, CURLOPT_HTTPHEADER, mHeaders); | ||
182 | |||
183 | mOutput.str(""); | ||
184 | if (!((istream&)mOutput).good()) { | ||
185 | std::cerr << "WHAT!?!?!? istream side bad" << std::endl; | ||
186 | } | ||
187 | if (!((ostream&)mOutput).good()) { | ||
188 | std::cerr << "WHAT!?!?!? ostream side bad" << std::endl; | ||
189 | } | ||
190 | |||
191 | mURL = url; | ||
192 | curl_easy_setopt(mHandle, CURLOPT_URL, mURL.c_str()); | ||
193 | |||
194 | mResponder = responder; | ||
195 | } | ||
196 | |||
197 | void | ||
198 | LLCurl::Easy::report(CURLcode code) | ||
199 | { | ||
200 | if (!mResponder) return; | ||
201 | |||
202 | long responseCode; | ||
203 | |||
204 | if (code == CURLE_OK) | ||
205 | { | ||
206 | curl_easy_getinfo(mHandle, CURLINFO_RESPONSE_CODE, &responseCode); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | responseCode = 499; | ||
211 | } | ||
212 | |||
213 | mResponder->completed(responseCode, mOutput); | ||
214 | mResponder = NULL; | ||
215 | } | ||
216 | |||
217 | |||
218 | |||
219 | |||
220 | |||
221 | |||
222 | LLCurl::Multi::Multi() | ||
223 | { | ||
224 | mHandle = curl_multi_init(); | ||
225 | } | ||
226 | |||
227 | LLCurl::Multi::~Multi() | ||
228 | { | ||
229 | // FIXME: should clean up excess handles in mFreeEasy | ||
230 | curl_multi_cleanup(mHandle); | ||
231 | } | ||
232 | |||
233 | |||
234 | void | ||
235 | LLCurl::Multi::get(const std::string& url, ResponderPtr responder) | ||
236 | { | ||
237 | LLCurl::Easy* easy = easyAlloc(); | ||
238 | easy->get(url, responder); | ||
239 | curl_multi_add_handle(mHandle, easy->mHandle); | ||
240 | } | ||
241 | |||
242 | void | ||
243 | LLCurl::Multi::getByteRange(const std::string& url, S32 offset, S32 length, ResponderPtr responder) | ||
244 | { | ||
245 | LLCurl::Easy* easy = easyAlloc(); | ||
246 | easy->getByteRange(url, offset, length, responder); | ||
247 | curl_multi_add_handle(mHandle, easy->mHandle); | ||
248 | } | ||
249 | |||
250 | void | ||
251 | LLCurl::Multi::process() | ||
252 | { | ||
253 | int count; | ||
254 | for (int call_count = 0; call_count < 5; call_count += 1) | ||
255 | { | ||
256 | if (CURLM_CALL_MULTI_PERFORM != curl_multi_perform(mHandle, &count)) | ||
257 | { | ||
258 | break; | ||
259 | } | ||
260 | } | ||
261 | |||
262 | CURLMsg* msg; | ||
263 | int msgs_in_queue; | ||
264 | while ((msg = curl_multi_info_read(mHandle, &msgs_in_queue))) | ||
265 | { | ||
266 | if (msg->msg != CURLMSG_DONE) continue; | ||
267 | Easy* easy = 0; | ||
268 | curl_easy_getinfo(msg->easy_handle, CURLINFO_PRIVATE, &easy); | ||
269 | if (!easy) continue; | ||
270 | easy->report(msg->data.result); | ||
271 | |||
272 | curl_multi_remove_handle(mHandle, easy->mHandle); | ||
273 | easyFree(easy); | ||
274 | } | ||
275 | } | ||
276 | |||
277 | |||
278 | |||
279 | LLCurl::Easy* | ||
280 | LLCurl::Multi::easyAlloc() | ||
281 | { | ||
282 | Easy* easy = 0; | ||
283 | |||
284 | if (mFreeEasy.empty()) | ||
285 | { | ||
286 | easy = new Easy(); | ||
287 | } | ||
288 | else | ||
289 | { | ||
290 | easy = mFreeEasy.back(); | ||
291 | mFreeEasy.pop_back(); | ||
292 | } | ||
293 | |||
294 | return easy; | ||
295 | } | ||
296 | |||
297 | void | ||
298 | LLCurl::Multi::easyFree(Easy* easy) | ||
299 | { | ||
300 | if (mFreeEasy.size() < 5) | ||
301 | { | ||
302 | mFreeEasy.push_back(easy); | ||
303 | } | ||
304 | else | ||
305 | { | ||
306 | delete easy; | ||
307 | } | ||
308 | } | ||
309 | |||
310 | |||
311 | |||
312 | namespace | ||
313 | { | ||
314 | static LLCurl::Multi* sMainMulti = 0; | ||
315 | |||
316 | LLCurl::Multi* | ||
317 | mainMulti() | ||
318 | { | ||
319 | if (!sMainMulti) { | ||
320 | sMainMulti = new LLCurl::Multi(); | ||
321 | } | ||
322 | return sMainMulti; | ||
323 | } | ||
324 | } | ||
325 | |||
326 | void | ||
327 | LLCurl::get(const std::string& url, ResponderPtr responder) | ||
328 | { | ||
329 | mainMulti()->get(url, responder); | ||
330 | } | ||
331 | |||
332 | void | ||
333 | LLCurl::getByteRange(const std::string& url, S32 offset, S32 length, ResponderPtr responder) | ||
334 | { | ||
335 | mainMulti()->getByteRange(url, offset, length, responder); | ||
336 | } | ||
337 | |||
338 | void | ||
339 | LLCurl::process() | ||
340 | { | ||
341 | mainMulti()->process(); | ||
342 | } | ||
343 | |||
diff --git a/linden/indra/llmessage/llcurl.h b/linden/indra/llmessage/llcurl.h new file mode 100644 index 0000000..4f1b5e6 --- /dev/null +++ b/linden/indra/llmessage/llcurl.h | |||
@@ -0,0 +1,118 @@ | |||
1 | /* | ||
2 | * llcurl.h | ||
3 | * MacTester | ||
4 | * | ||
5 | * Created by Zero Linden on 10/15/06. | ||
6 | * Copyright 2006 __MyCompanyName__. All rights reserved. | ||
7 | * | ||
8 | */ | ||
9 | |||
10 | #ifndef LL_LLCURL_H | ||
11 | #define LL_LLCURL_H | ||
12 | |||
13 | #include "linden_common.h" | ||
14 | |||
15 | #include <sstream> | ||
16 | #include <string> | ||
17 | #include <vector> | ||
18 | |||
19 | #include <boost/intrusive_ptr.hpp> | ||
20 | #include <curl/curl.h> | ||
21 | |||
22 | // #include "llhttpclient.h" | ||
23 | |||
24 | class LLCurl | ||
25 | { | ||
26 | public: | ||
27 | class Multi; | ||
28 | |||
29 | class Responder | ||
30 | { | ||
31 | public: | ||
32 | Responder(); | ||
33 | virtual ~Responder(); | ||
34 | |||
35 | virtual void error(U32 status, const std::stringstream& content); // called with bad status codes | ||
36 | |||
37 | virtual void result(const std::stringstream& content); | ||
38 | |||
39 | virtual void completed(U32 status, const std::stringstream& content); | ||
40 | /**< The default implemetnation calls | ||
41 | either: | ||
42 | * result(), or | ||
43 | * error() | ||
44 | */ | ||
45 | |||
46 | public: /* but not really -- don't touch this */ | ||
47 | U32 mReferenceCount; | ||
48 | }; | ||
49 | typedef boost::intrusive_ptr<Responder> ResponderPtr; | ||
50 | |||
51 | class Easy | ||
52 | { | ||
53 | public: | ||
54 | Easy(); | ||
55 | ~Easy(); | ||
56 | |||
57 | void get(const std::string& url, ResponderPtr); | ||
58 | void getByteRange(const std::string& url, S32 offset, S32 length, ResponderPtr); | ||
59 | |||
60 | void perform(); | ||
61 | |||
62 | private: | ||
63 | void prep(const std::string& url, ResponderPtr); | ||
64 | void report(CURLcode); | ||
65 | |||
66 | CURL* mHandle; | ||
67 | struct curl_slist* mHeaders; | ||
68 | |||
69 | std::string mURL; | ||
70 | std::string mRange; | ||
71 | std::stringstream mRequest; | ||
72 | |||
73 | std::stringstream mOutput; | ||
74 | char mErrorBuffer[CURL_ERROR_SIZE]; | ||
75 | |||
76 | std::stringstream mHeaderOutput; // Debug | ||
77 | |||
78 | ResponderPtr mResponder; | ||
79 | |||
80 | friend class Multi; | ||
81 | }; | ||
82 | |||
83 | |||
84 | class Multi | ||
85 | { | ||
86 | public: | ||
87 | Multi(); | ||
88 | ~Multi(); | ||
89 | |||
90 | void get(const std::string& url, ResponderPtr); | ||
91 | void getByteRange(const std::string& url, S32 offset, S32 length, ResponderPtr); | ||
92 | |||
93 | void process(); | ||
94 | |||
95 | private: | ||
96 | Easy* easyAlloc(); | ||
97 | void easyFree(Easy*); | ||
98 | |||
99 | CURLM* mHandle; | ||
100 | |||
101 | typedef std::vector<Easy*> EasyList; | ||
102 | EasyList mFreeEasy; | ||
103 | }; | ||
104 | |||
105 | |||
106 | static void get(const std::string& url, ResponderPtr); | ||
107 | static void getByteRange(const std::string& url, S32 offset, S32 length, ResponderPtr responder); | ||
108 | |||
109 | static void process(); | ||
110 | }; | ||
111 | |||
112 | namespace boost | ||
113 | { | ||
114 | void intrusive_ptr_add_ref(LLCurl::Responder* p); | ||
115 | void intrusive_ptr_release(LLCurl::Responder* p); | ||
116 | }; | ||
117 | |||
118 | #endif // LL_LLCURL_H | ||
diff --git a/linden/indra/llmessage/lldatapacker.cpp b/linden/indra/llmessage/lldatapacker.cpp index 4a15d8b..d4c8704 100644 --- a/linden/indra/llmessage/lldatapacker.cpp +++ b/linden/indra/llmessage/lldatapacker.cpp | |||
@@ -543,7 +543,7 @@ const LLDataPackerBinaryBuffer& LLDataPackerBinaryBuffer::operator=(const LLData | |||
543 | // We've got problems, ack! | 543 | // We've got problems, ack! |
544 | llerrs << "Trying to do an assignment with not enough room in the target." << llendl; | 544 | llerrs << "Trying to do an assignment with not enough room in the target." << llendl; |
545 | } | 545 | } |
546 | memcpy(mBufferp, a.mBufferp, a.getBufferSize()); | 546 | memcpy(mBufferp, a.mBufferp, a.getBufferSize()); /*Flawfinder: ignore*/ |
547 | return *this; | 547 | return *this; |
548 | } | 548 | } |
549 | 549 | ||
@@ -1236,7 +1236,7 @@ BOOL LLDataPackerAsciiBuffer::unpackUUID(LLUUID &value, const char *name) | |||
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | char tmp_str[64]; /* Flawfinder: ignore */ | 1238 | char tmp_str[64]; /* Flawfinder: ignore */ |
1239 | sscanf(valuestr, "%63s", tmp_str); | 1239 | sscanf(valuestr, "%63s", tmp_str); /* Flawfinder: ignore */ |
1240 | value.set(tmp_str); | 1240 | value.set(tmp_str); |
1241 | 1241 | ||
1242 | return success; | 1242 | return success; |
@@ -1258,7 +1258,7 @@ void LLDataPackerAsciiBuffer::writeIndentedName(const char *name) | |||
1258 | } | 1258 | } |
1259 | else | 1259 | else |
1260 | { | 1260 | { |
1261 | numCopied = (S32)strlen(name) + 1; //name + tab /* Flawfinder: ignore */ | 1261 | numCopied = (S32)strlen(name) + 1; /* Flawfinder: ignore */ //name + tab |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | // snprintf returns number of bytes that would have been written had the | 1264 | // snprintf returns number of bytes that would have been written had the |
@@ -1288,9 +1288,9 @@ BOOL LLDataPackerAsciiBuffer::getValueStr(const char *name, char *out_value, S32 | |||
1288 | // Read both the name and the value, and validate the name. | 1288 | // Read both the name and the value, and validate the name. |
1289 | sscanf(mCurBufferp, "%511[^\n]", buffer); | 1289 | sscanf(mCurBufferp, "%511[^\n]", buffer); |
1290 | // Skip the \n | 1290 | // Skip the \n |
1291 | mCurBufferp += (S32)strlen(buffer) + 1; | 1291 | mCurBufferp += (S32)strlen(buffer) + 1; /* Flawfinder: ignore */ |
1292 | 1292 | ||
1293 | sscanf(buffer, "%511s %511[^\n]", keyword, value); | 1293 | sscanf(buffer, "%511s %511[^\n]", keyword, value); /* Flawfinder: ignore */ |
1294 | 1294 | ||
1295 | if (strcmp(keyword, name)) | 1295 | if (strcmp(keyword, name)) |
1296 | { | 1296 | { |
@@ -1794,7 +1794,7 @@ BOOL LLDataPackerAsciiFile::unpackUUID(LLUUID &value, const char *name) | |||
1794 | } | 1794 | } |
1795 | 1795 | ||
1796 | char tmp_str[64]; /*Flawfinder: ignore */ | 1796 | char tmp_str[64]; /*Flawfinder: ignore */ |
1797 | sscanf(valuestr,"%63s",tmp_str); | 1797 | sscanf(valuestr,"%63s",tmp_str); /* Flawfinder: ignore */ |
1798 | value.set(tmp_str); | 1798 | value.set(tmp_str); |
1799 | 1799 | ||
1800 | return success; | 1800 | return success; |
@@ -1838,7 +1838,7 @@ BOOL LLDataPackerAsciiFile::getValueStr(const char *name, char *out_value, S32 v | |||
1838 | fgetpos(mFP, &last_pos); | 1838 | fgetpos(mFP, &last_pos); |
1839 | fgets(buffer, DP_BUFSIZE, mFP); | 1839 | fgets(buffer, DP_BUFSIZE, mFP); |
1840 | 1840 | ||
1841 | sscanf(buffer, "%511s %511[^\n]", keyword, value); | 1841 | sscanf(buffer, "%511s %511[^\n]", keyword, value); /* Flawfinder: ignore */ |
1842 | 1842 | ||
1843 | if (!keyword[0]) | 1843 | if (!keyword[0]) |
1844 | { | 1844 | { |
@@ -1863,7 +1863,7 @@ BOOL LLDataPackerAsciiFile::getValueStr(const char *name, char *out_value, S32 v | |||
1863 | { | 1863 | { |
1864 | mInputStream->getline(buffer, DP_BUFSIZE); | 1864 | mInputStream->getline(buffer, DP_BUFSIZE); |
1865 | 1865 | ||
1866 | sscanf(buffer, "%511s %511[^\n]", keyword, value); | 1866 | sscanf(buffer, "%511s %511[^\n]", keyword, value); /* Flawfinder: ignore */ |
1867 | if (!keyword[0]) | 1867 | if (!keyword[0]) |
1868 | { | 1868 | { |
1869 | llwarns << "Data packer could not get the keyword!" << llendl; | 1869 | llwarns << "Data packer could not get the keyword!" << llendl; |
diff --git a/linden/indra/llmessage/lldispatcher.cpp b/linden/indra/llmessage/lldispatcher.cpp index cf83079..7ba9f44 100644 --- a/linden/indra/llmessage/lldispatcher.cpp +++ b/linden/indra/llmessage/lldispatcher.cpp | |||
@@ -76,6 +76,7 @@ bool LLDispatcher::dispatch( | |||
76 | LLDispatchHandler* func = (*it).second; | 76 | LLDispatchHandler* func = (*it).second; |
77 | return (*func)(this, name, invoice, strings); | 77 | return (*func)(this, name, invoice, strings); |
78 | } | 78 | } |
79 | llwarns << "Unable to find handler for Generic message: " << name << llendl; | ||
79 | return false; | 80 | return false; |
80 | } | 81 | } |
81 | 82 | ||
diff --git a/linden/indra/llmessage/llfiltersd2xmlrpc.cpp b/linden/indra/llmessage/llfiltersd2xmlrpc.cpp index feae47a..63913d5 100644 --- a/linden/indra/llmessage/llfiltersd2xmlrpc.cpp +++ b/linden/indra/llmessage/llfiltersd2xmlrpc.cpp | |||
@@ -267,6 +267,7 @@ void LLFilterSD2XMLRPC::streamOut(std::ostream& ostr, const LLSD& sd) | |||
267 | LLSD::Binary buffer = sd.asBinary(); | 267 | LLSD::Binary buffer = sd.asBinary(); |
268 | if(!buffer.empty()) | 268 | if(!buffer.empty()) |
269 | { | 269 | { |
270 | // *TODO: convert to LLBase64 | ||
270 | int b64_buffer_length = apr_base64_encode_len(buffer.size()); | 271 | int b64_buffer_length = apr_base64_encode_len(buffer.size()); |
271 | char* b64_buffer = new char[b64_buffer_length]; | 272 | char* b64_buffer = new char[b64_buffer_length]; |
272 | b64_buffer_length = apr_base64_encode_binary( | 273 | b64_buffer_length = apr_base64_encode_binary( |
diff --git a/linden/indra/llmessage/llhost.cpp b/linden/indra/llmessage/llhost.cpp index c071063..c1ca4b0 100644 --- a/linden/indra/llmessage/llhost.cpp +++ b/linden/indra/llmessage/llhost.cpp | |||
@@ -87,7 +87,7 @@ void LLHost::getIPString(char* buffer, S32 length) const | |||
87 | 87 | ||
88 | std::string LLHost::getIPandPort() const | 88 | std::string LLHost::getIPandPort() const |
89 | { | 89 | { |
90 | char buffer[MAXADDRSTR + 1 + 5]; | 90 | char buffer[MAXADDRSTR + 1 + 5]; /*Flawfinder: ignore*/ |
91 | getString(buffer, sizeof(buffer)); | 91 | getString(buffer, sizeof(buffer)); |
92 | return buffer; | 92 | return buffer; |
93 | } | 93 | } |
diff --git a/linden/indra/llmessage/llhttpassetstorage.cpp b/linden/indra/llmessage/llhttpassetstorage.cpp index 2b64385..6c57499 100644 --- a/linden/indra/llmessage/llhttpassetstorage.cpp +++ b/linden/indra/llmessage/llhttpassetstorage.cpp | |||
@@ -30,12 +30,15 @@ | |||
30 | 30 | ||
31 | #include "llhttpassetstorage.h" | 31 | #include "llhttpassetstorage.h" |
32 | 32 | ||
33 | #include <sys/stat.h> | ||
34 | |||
33 | #include "indra_constants.h" | 35 | #include "indra_constants.h" |
34 | #include "llvfile.h" | 36 | #include "llvfile.h" |
35 | #include "llvfs.h" | 37 | #include "llvfs.h" |
36 | 38 | ||
37 | #include "zlib/zlib.h" | 39 | #include "zlib/zlib.h" |
38 | 40 | ||
41 | const U32 MAX_RUNNING_REQUESTS = 4; | ||
39 | const F32 MAX_PROCESSING_TIME = 0.005f; | 42 | const F32 MAX_PROCESSING_TIME = 0.005f; |
40 | const S32 CURL_XFER_BUFFER_SIZE = 65536; | 43 | const S32 CURL_XFER_BUFFER_SIZE = 65536; |
41 | // Try for 30 minutes for now. | 44 | // Try for 30 minutes for now. |
@@ -68,7 +71,9 @@ struct LLTempAssetData | |||
68 | class LLHTTPAssetRequest : public LLAssetRequest | 71 | class LLHTTPAssetRequest : public LLAssetRequest |
69 | { | 72 | { |
70 | public: | 73 | public: |
71 | LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, LLAssetType::EType type, const char *url, CURLM *curl_multi); | 74 | LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, |
75 | LLAssetType::EType type, LLAssetStorage::ERequestType rt, | ||
76 | const char *url, CURLM *curl_multi); | ||
72 | virtual ~LLHTTPAssetRequest(); | 77 | virtual ~LLHTTPAssetRequest(); |
73 | 78 | ||
74 | void setupCurlHandle(); | 79 | void setupCurlHandle(); |
@@ -80,6 +85,9 @@ public: | |||
80 | static size_t curlCompressedUploadCallback( | 85 | static size_t curlCompressedUploadCallback( |
81 | void *data, size_t size, size_t nmemb, void *user_data); | 86 | void *data, size_t size, size_t nmemb, void *user_data); |
82 | 87 | ||
88 | virtual LLSD getTerseDetails() const; | ||
89 | virtual LLSD getFullDetails() const; | ||
90 | |||
83 | public: | 91 | public: |
84 | LLHTTPAssetStorage *mAssetStoragep; | 92 | LLHTTPAssetStorage *mAssetStoragep; |
85 | 93 | ||
@@ -89,9 +97,7 @@ public: | |||
89 | struct curl_slist *mHTTPHeaders; | 97 | struct curl_slist *mHTTPHeaders; |
90 | LLVFile *mVFile; | 98 | LLVFile *mVFile; |
91 | LLUUID mTmpUUID; | 99 | LLUUID mTmpUUID; |
92 | BOOL mIsUpload; | 100 | LLAssetStorage::ERequestType mRequestType; |
93 | BOOL mIsLocalUpload; | ||
94 | BOOL mIsDownload; | ||
95 | 101 | ||
96 | bool mZInitialized; | 102 | bool mZInitialized; |
97 | z_stream mZStream; | 103 | z_stream mZStream; |
@@ -102,7 +108,12 @@ public: | |||
102 | }; | 108 | }; |
103 | 109 | ||
104 | 110 | ||
105 | LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uuid, LLAssetType::EType type, const char *url, CURLM *curl_multi) | 111 | LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, |
112 | const LLUUID &uuid, | ||
113 | LLAssetType::EType type, | ||
114 | LLAssetStorage::ERequestType rt, | ||
115 | const char *url, | ||
116 | CURLM *curl_multi) | ||
106 | : LLAssetRequest(uuid, type), | 117 | : LLAssetRequest(uuid, type), |
107 | mZInitialized(false) | 118 | mZInitialized(false) |
108 | { | 119 | { |
@@ -110,15 +121,16 @@ LLHTTPAssetRequest::LLHTTPAssetRequest(LLHTTPAssetStorage *asp, const LLUUID &uu | |||
110 | mCurlHandle = NULL; | 121 | mCurlHandle = NULL; |
111 | mCurlMultiHandle = curl_multi; | 122 | mCurlMultiHandle = curl_multi; |
112 | mVFile = NULL; | 123 | mVFile = NULL; |
113 | mIsUpload = FALSE; | 124 | mRequestType = rt; |
114 | mIsLocalUpload = FALSE; | ||
115 | mIsDownload = FALSE; | ||
116 | mHTTPHeaders = NULL; | 125 | mHTTPHeaders = NULL; |
126 | mFP = NULL; | ||
127 | mZInputBuffer = NULL; | ||
128 | mZInputExhausted = false; | ||
117 | 129 | ||
118 | mURLBuffer = new char[strlen(url) + 1]; /*Flawfinder: ignore*/ | 130 | mURLBuffer = new char[strlen(url) + 1]; /*Flawfinder: ignore*/ |
119 | if (mURLBuffer) | 131 | if (mURLBuffer) |
120 | { | 132 | { |
121 | strcpy(mURLBuffer, url); | 133 | strcpy(mURLBuffer, url); /*Flawfinder: ignore*/ |
122 | } | 134 | } |
123 | } | 135 | } |
124 | 136 | ||
@@ -132,22 +144,7 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest() | |||
132 | if (mAssetStoragep) | 144 | if (mAssetStoragep) |
133 | { | 145 | { |
134 | // Terminating a request. Thus upload or download is no longer pending. | 146 | // Terminating a request. Thus upload or download is no longer pending. |
135 | if (mIsUpload) | 147 | mAssetStoragep->removeRunningRequest(mRequestType, this); |
136 | { | ||
137 | mAssetStoragep->clearPendingUpload(); | ||
138 | } | ||
139 | else if (mIsLocalUpload) | ||
140 | { | ||
141 | mAssetStoragep->clearPendingLocalUpload(); | ||
142 | } | ||
143 | else if (mIsDownload) | ||
144 | { | ||
145 | mAssetStoragep->clearPendingDownload(); | ||
146 | } | ||
147 | else | ||
148 | { | ||
149 | llerrs << "LLHTTPAssetRequest::~LLHTTPAssetRequest - Destroyed request is not upload OR download, this is bad!" << llendl; | ||
150 | } | ||
151 | } | 148 | } |
152 | else | 149 | else |
153 | { | 150 | { |
@@ -163,6 +160,82 @@ LLHTTPAssetRequest::~LLHTTPAssetRequest() | |||
163 | finishCompressedUpload(); | 160 | finishCompressedUpload(); |
164 | } | 161 | } |
165 | 162 | ||
163 | // virtual | ||
164 | LLSD LLHTTPAssetRequest::getTerseDetails() const | ||
165 | { | ||
166 | LLSD sd = LLAssetRequest::getTerseDetails(); | ||
167 | |||
168 | sd["url"] = mURLBuffer; | ||
169 | |||
170 | return sd; | ||
171 | } | ||
172 | |||
173 | // virtual | ||
174 | LLSD LLHTTPAssetRequest::getFullDetails() const | ||
175 | { | ||
176 | LLSD sd = LLAssetRequest::getFullDetails(); | ||
177 | |||
178 | if (mCurlHandle) | ||
179 | { | ||
180 | long curl_response = -1; | ||
181 | long curl_connect = -1; | ||
182 | double curl_total_time = -1.0f; | ||
183 | double curl_size_upload = -1.0f; | ||
184 | double curl_size_download = -1.0f; | ||
185 | long curl_content_length_upload = -1; | ||
186 | long curl_content_length_download = -1; | ||
187 | long curl_request_size = -1; | ||
188 | const char* curl_content_type = NULL; | ||
189 | |||
190 | curl_easy_getinfo(mCurlHandle, CURLINFO_HTTP_CODE, &curl_response); | ||
191 | curl_easy_getinfo(mCurlHandle, CURLINFO_HTTP_CONNECTCODE, &curl_connect); | ||
192 | curl_easy_getinfo(mCurlHandle, CURLINFO_TOTAL_TIME, &curl_total_time); | ||
193 | curl_easy_getinfo(mCurlHandle, CURLINFO_SIZE_UPLOAD, &curl_size_upload); | ||
194 | curl_easy_getinfo(mCurlHandle, CURLINFO_SIZE_DOWNLOAD, &curl_size_download); | ||
195 | curl_easy_getinfo(mCurlHandle, CURLINFO_CONTENT_LENGTH_UPLOAD, &curl_content_length_upload); | ||
196 | curl_easy_getinfo(mCurlHandle, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &curl_content_length_download); | ||
197 | curl_easy_getinfo(mCurlHandle, CURLINFO_REQUEST_SIZE, &curl_request_size); | ||
198 | curl_easy_getinfo(mCurlHandle, CURLINFO_CONTENT_TYPE, &curl_content_type); | ||
199 | |||
200 | sd["curl_response_code"] = (int) curl_response; | ||
201 | sd["curl_http_connect_code"] = (int) curl_connect; | ||
202 | sd["curl_total_time"] = curl_total_time; | ||
203 | sd["curl_size_upload"] = curl_size_upload; | ||
204 | sd["curl_size_download"] = curl_size_download; | ||
205 | sd["curl_content_length_upload"] = (int) curl_content_length_upload; | ||
206 | sd["curl_content_length_download"] = (int) curl_content_length_download; | ||
207 | sd["curl_request_size"] = (int) curl_request_size; | ||
208 | if (curl_content_type) | ||
209 | { | ||
210 | sd["curl_content_type"] = curl_content_type; | ||
211 | } | ||
212 | else | ||
213 | { | ||
214 | sd["curl_content_type"] = ""; | ||
215 | } | ||
216 | } | ||
217 | |||
218 | sd["temp_id"] = mTmpUUID; | ||
219 | sd["request_type"] = LLAssetStorage::getRequestName(mRequestType); | ||
220 | sd["z_initialized"] = mZInitialized; | ||
221 | sd["z_input_exhausted"] = mZInputExhausted; | ||
222 | |||
223 | S32 file_size = -1; | ||
224 | if (mFP) | ||
225 | { | ||
226 | struct stat file_stat; | ||
227 | int file_desc = fileno(mFP); | ||
228 | if ( fstat(file_desc, &file_stat) == 0) | ||
229 | { | ||
230 | file_size = file_stat.st_size; | ||
231 | } | ||
232 | } | ||
233 | sd["file_size"] = file_size; | ||
234 | |||
235 | return sd; | ||
236 | } | ||
237 | |||
238 | |||
166 | void LLHTTPAssetRequest::setupCurlHandle() | 239 | void LLHTTPAssetRequest::setupCurlHandle() |
167 | { | 240 | { |
168 | mCurlHandle = curl_easy_init(); | 241 | mCurlHandle = curl_easy_init(); |
@@ -170,7 +243,7 @@ void LLHTTPAssetRequest::setupCurlHandle() | |||
170 | curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); | 243 | curl_easy_setopt(mCurlHandle, CURLOPT_NOPROGRESS, 1); |
171 | curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer); | 244 | curl_easy_setopt(mCurlHandle, CURLOPT_URL, mURLBuffer); |
172 | curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); | 245 | curl_easy_setopt(mCurlHandle, CURLOPT_PRIVATE, this); |
173 | if (mIsDownload) | 246 | if (LLAssetStorage::RT_DOWNLOAD == mRequestType) |
174 | { | 247 | { |
175 | curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); | 248 | curl_easy_setopt(mCurlHandle, CURLOPT_ENCODING, ""); |
176 | // only do this on downloads, as uploads | 249 | // only do this on downloads, as uploads |
@@ -193,22 +266,7 @@ void LLHTTPAssetRequest::setupCurlHandle() | |||
193 | if (mAssetStoragep) | 266 | if (mAssetStoragep) |
194 | { | 267 | { |
195 | // Set the appropriate pending upload or download flag | 268 | // Set the appropriate pending upload or download flag |
196 | if (mIsUpload) | 269 | mAssetStoragep->addRunningRequest(mRequestType, this); |
197 | { | ||
198 | mAssetStoragep->setPendingUpload(); | ||
199 | } | ||
200 | else if (mIsLocalUpload) | ||
201 | { | ||
202 | mAssetStoragep->setPendingLocalUpload(); | ||
203 | } | ||
204 | else if (mIsDownload) | ||
205 | { | ||
206 | mAssetStoragep->setPendingDownload(); | ||
207 | } | ||
208 | else | ||
209 | { | ||
210 | llerrs << "LLHTTPAssetRequest::setupCurlHandle - Request is not upload OR download, this is bad!" << llendl; | ||
211 | } | ||
212 | } | 270 | } |
213 | else | 271 | else |
214 | { | 272 | { |
@@ -342,10 +400,6 @@ void LLHTTPAssetStorage::_init(const char *web_host, const char *local_web_host, | |||
342 | curl_global_init(CURL_GLOBAL_ALL); | 400 | curl_global_init(CURL_GLOBAL_ALL); |
343 | 401 | ||
344 | mCurlMultiHandle = curl_multi_init(); | 402 | mCurlMultiHandle = curl_multi_init(); |
345 | |||
346 | mPendingDownload = FALSE; | ||
347 | mPendingUpload = FALSE; | ||
348 | mPendingLocalUpload = FALSE; | ||
349 | } | 403 | } |
350 | 404 | ||
351 | LLHTTPAssetStorage::~LLHTTPAssetStorage() | 405 | LLHTTPAssetStorage::~LLHTTPAssetStorage() |
@@ -457,6 +511,113 @@ void LLHTTPAssetStorage::storeAssetData( | |||
457 | } | 511 | } |
458 | } | 512 | } |
459 | 513 | ||
514 | // virtual | ||
515 | LLSD LLHTTPAssetStorage::getPendingDetails(LLAssetStorage::ERequestType rt, | ||
516 | LLAssetType::EType asset_type, | ||
517 | const std::string& detail_prefix) const | ||
518 | { | ||
519 | LLSD sd = LLAssetStorage::getPendingDetails(rt, asset_type, detail_prefix); | ||
520 | const request_list_t* running = getRunningList(rt); | ||
521 | if (running) | ||
522 | { | ||
523 | // Loop through the pending requests sd, and add extra info about its running status. | ||
524 | S32 num_pending = sd["requests"].size(); | ||
525 | S32 i; | ||
526 | for (i = 0; i < num_pending; ++i) | ||
527 | { | ||
528 | LLSD& pending = sd["requests"][i]; | ||
529 | // See if this pending request is running. | ||
530 | const LLAssetRequest* req = findRequest(running, | ||
531 | LLAssetType::lookup(pending["type"].asString().c_str()), | ||
532 | pending["asset_id"]); | ||
533 | if (req) | ||
534 | { | ||
535 | // Keep the detail_url so we don't have to rebuild it. | ||
536 | LLURI detail_url = pending["detail"]; | ||
537 | pending = req->getTerseDetails(); | ||
538 | pending["detail"] = detail_url; | ||
539 | pending["is_running"] = true; | ||
540 | } | ||
541 | else | ||
542 | { | ||
543 | pending["is_running"] = false; | ||
544 | } | ||
545 | } | ||
546 | } | ||
547 | return sd; | ||
548 | } | ||
549 | |||
550 | // virtual | ||
551 | LLSD LLHTTPAssetStorage::getPendingRequest(LLAssetStorage::ERequestType rt, | ||
552 | LLAssetType::EType asset_type, | ||
553 | const LLUUID& asset_id) const | ||
554 | { | ||
555 | // Look for this asset in the running list first. | ||
556 | const request_list_t* running = getRunningList(rt); | ||
557 | if (running) | ||
558 | { | ||
559 | LLSD sd = LLAssetStorage::getPendingRequest(running, asset_type, asset_id); | ||
560 | if (sd) | ||
561 | { | ||
562 | sd["is_running"] = true; | ||
563 | return sd; | ||
564 | } | ||
565 | } | ||
566 | LLSD sd = LLAssetStorage::getPendingRequest(rt, asset_type, asset_id); | ||
567 | if (sd) | ||
568 | { | ||
569 | sd["is_running"] = false; | ||
570 | } | ||
571 | return sd; | ||
572 | } | ||
573 | |||
574 | // virtual | ||
575 | bool LLHTTPAssetStorage::deletePendingRequest(LLAssetStorage::ERequestType rt, | ||
576 | LLAssetType::EType asset_type, | ||
577 | const LLUUID& asset_id) | ||
578 | { | ||
579 | // Try removing this from the running list first. | ||
580 | request_list_t* running = getRunningList(rt); | ||
581 | if (running) | ||
582 | { | ||
583 | LLAssetRequest* req = findRequest(running, asset_type, asset_id); | ||
584 | if (req) | ||
585 | { | ||
586 | // Remove this request from the running list to get it out of curl. | ||
587 | running->remove(req); | ||
588 | |||
589 | // Find this request in the pending list, so we can move it to the end of the line. | ||
590 | request_list_t* pending = getRequestList(rt); | ||
591 | if (pending) | ||
592 | { | ||
593 | request_list_t::iterator result = std::find_if(pending->begin(), pending->end(), | ||
594 | std::bind2nd(ll_asset_request_equal<LLAssetRequest*>(), req)); | ||
595 | if (pending->end() != result) | ||
596 | { | ||
597 | // This request was found in the pending list. Move it to the end! | ||
598 | LLAssetRequest* pending_req = *result; | ||
599 | pending->remove(pending_req); | ||
600 | pending->push_back(pending_req); | ||
601 | |||
602 | llinfos << "Asset " << getRequestName(rt) << " request for " | ||
603 | << asset_id << "." << LLAssetType::lookup(asset_type) | ||
604 | << " removed from curl and placed at the end of the pending queue." | ||
605 | << llendl; | ||
606 | } | ||
607 | else | ||
608 | { | ||
609 | llwarns << "Unable to find pending " << getRequestName(rt) << " request for " | ||
610 | << asset_id << "." << LLAssetType::lookup(asset_type) << llendl; | ||
611 | } | ||
612 | } | ||
613 | delete req; | ||
614 | |||
615 | return true; | ||
616 | } | ||
617 | } | ||
618 | return LLAssetStorage::deletePendingRequest(rt, asset_type, asset_id); | ||
619 | } | ||
620 | |||
460 | // internal requester, used by getAssetData in superclass | 621 | // internal requester, used by getAssetData in superclass |
461 | void LLHTTPAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType type, | 622 | void LLHTTPAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::EType type, |
462 | void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32), | 623 | void (*callback)(LLVFS *vfs, const LLUUID&, LLAssetType::EType, void *, S32), |
@@ -488,13 +649,41 @@ void LLHTTPAssetStorage::_queueDataRequest(const LLUUID& uuid, LLAssetType::ETyp | |||
488 | } | 649 | } |
489 | } | 650 | } |
490 | 651 | ||
652 | LLAssetRequest* LLHTTPAssetStorage::findNextRequest(LLAssetStorage::request_list_t& pending, | ||
653 | LLAssetStorage::request_list_t& running) | ||
654 | { | ||
655 | // Early exit if the running list is full, or we don't have more pending than running. | ||
656 | if (running.size() >= MAX_RUNNING_REQUESTS | ||
657 | || pending.size() <= running.size()) return NULL; | ||
658 | |||
659 | // Look for the first pending request that is not already running. | ||
660 | request_list_t::iterator running_begin = running.begin(); | ||
661 | request_list_t::iterator running_end = running.end(); | ||
662 | |||
663 | request_list_t::iterator pending_iter = pending.begin(); | ||
664 | request_list_t::iterator pending_end = pending.end(); | ||
665 | // Loop over all pending requests until we miss finding it in the running list. | ||
666 | for (; pending_iter != pending.end(); ++pending_iter) | ||
667 | { | ||
668 | LLAssetRequest* req = *pending_iter; | ||
669 | // Look for this pending request in the running list. | ||
670 | if (running_end == std::find_if(running_begin, running_end, | ||
671 | std::bind2nd(ll_asset_request_equal<LLAssetRequest*>(), req))) | ||
672 | { | ||
673 | // It isn't running! Return it. | ||
674 | return req; | ||
675 | } | ||
676 | } | ||
677 | return NULL; | ||
678 | } | ||
679 | |||
491 | // overloaded to additionally move data to/from the webserver | 680 | // overloaded to additionally move data to/from the webserver |
492 | void LLHTTPAssetStorage::checkForTimeouts() | 681 | void LLHTTPAssetStorage::checkForTimeouts() |
493 | { | 682 | { |
494 | LLAssetRequest *req = NULL; | 683 | CURLMcode mcode; |
495 | if (mPendingDownloads.size() > 0 && !mPendingDownload) | 684 | LLAssetRequest *req; |
496 | { | 685 | while (req = findNextRequest(mPendingDownloads, mRunningDownloads)) |
497 | req = mPendingDownloads.front(); | 686 | { |
498 | // Setup this curl download request | 687 | // Setup this curl download request |
499 | // We need to generate a new request here | 688 | // We need to generate a new request here |
500 | // since the one in the list could go away | 689 | // since the one in the list could go away |
@@ -504,9 +693,9 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
504 | std::string base_url = getBaseURL(req->getUUID(), req->getType()); | 693 | std::string base_url = getBaseURL(req->getUUID(), req->getType()); |
505 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ | 694 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", base_url.c_str() , uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ |
506 | 695 | ||
507 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), tmp_url, mCurlMultiHandle); | 696 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
697 | req->getType(), RT_DOWNLOAD, tmp_url, mCurlMultiHandle); | ||
508 | new_req->mTmpUUID.generate(); | 698 | new_req->mTmpUUID.generate(); |
509 | new_req->mIsDownload = TRUE; | ||
510 | 699 | ||
511 | // Sets pending download flag internally | 700 | // Sets pending download flag internally |
512 | new_req->setupCurlHandle(); | 701 | new_req->setupCurlHandle(); |
@@ -514,15 +703,22 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
514 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_WRITEFUNCTION, &curlDownCallback); | 703 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_WRITEFUNCTION, &curlDownCallback); |
515 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_WRITEDATA, new_req->mCurlHandle); | 704 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_WRITEDATA, new_req->mCurlHandle); |
516 | 705 | ||
517 | curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); | 706 | mcode = curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); |
518 | llinfos << "Requesting " << new_req->mURLBuffer << llendl; | 707 | if (mcode > CURLM_OK) |
519 | 708 | { | |
709 | // Failure. Deleting the pending request will remove it from the running | ||
710 | // queue, and push it to the end of the pending queue. | ||
711 | deletePendingRequest(RT_DOWNLOAD, req->getType(), req->getUUID()); | ||
712 | break; | ||
713 | } | ||
714 | else | ||
715 | { | ||
716 | llinfos << "Requesting " << new_req->mURLBuffer << llendl; | ||
717 | } | ||
520 | } | 718 | } |
521 | 719 | ||
522 | 720 | while (req = findNextRequest(mPendingUploads, mRunningUploads)) | |
523 | if (mPendingUploads.size() > 0 && !mPendingUpload) | ||
524 | { | 721 | { |
525 | req = mPendingUploads.front(); | ||
526 | // setup this curl upload request | 722 | // setup this curl upload request |
527 | 723 | ||
528 | bool do_compress = req->getType() == LLAssetType::AT_OBJECT; | 724 | bool do_compress = req->getType() == LLAssetType::AT_OBJECT; |
@@ -534,8 +730,8 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
534 | do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", | 730 | do_compress ? "%s/%s.%s.gz" : "%s/%s.%s", |
535 | mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); | 731 | mBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); |
536 | 732 | ||
537 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), tmp_url, mCurlMultiHandle); | 733 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
538 | new_req->mIsUpload = TRUE; | 734 | req->getType(), RT_UPLOAD, tmp_url, mCurlMultiHandle); |
539 | if (do_compress) | 735 | if (do_compress) |
540 | { | 736 | { |
541 | new_req->prepareCompressedUpload(); | 737 | new_req->prepareCompressedUpload(); |
@@ -560,15 +756,23 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
560 | } | 756 | } |
561 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READDATA, new_req->mCurlHandle); | 757 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READDATA, new_req->mCurlHandle); |
562 | 758 | ||
563 | curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); | 759 | mcode = curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); |
564 | llinfos << "Requesting PUT " << new_req->mURLBuffer << llendl; | 760 | if (mcode > CURLM_OK) |
761 | { | ||
762 | // Failure. Deleting the pending request will remove it from the running | ||
763 | // queue, and push it to the end of the pending queue. | ||
764 | deletePendingRequest(RT_UPLOAD, req->getType(), req->getUUID()); | ||
765 | break; | ||
766 | } | ||
767 | else | ||
768 | { | ||
769 | llinfos << "Requesting PUT " << new_req->mURLBuffer << llendl; | ||
770 | } | ||
565 | // Pending upload will have been flagged by the request | 771 | // Pending upload will have been flagged by the request |
566 | } | 772 | } |
567 | 773 | ||
568 | 774 | while (req = findNextRequest(mPendingLocalUploads, mRunningLocalUploads)) | |
569 | if (mPendingLocalUploads.size() > 0 && !mPendingLocalUpload) | ||
570 | { | 775 | { |
571 | req = mPendingLocalUploads.front(); | ||
572 | // setup this curl upload request | 776 | // setup this curl upload request |
573 | LLVFile file(mVFS, req->getUUID(), req->getType()); | 777 | LLVFile file(mVFS, req->getUUID(), req->getType()); |
574 | 778 | ||
@@ -579,8 +783,8 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
579 | // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" | 783 | // KLW - All temporary uploads are saved locally "http://localhost:12041/asset" |
580 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ | 784 | snprintf(tmp_url, sizeof(tmp_url), "%s/%36s.%s", mLocalBaseURL.c_str(), uuid_str, LLAssetType::lookup(req->getType())); /*Flawfinder: ignore*/ |
581 | 785 | ||
582 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), req->getType(), tmp_url, mCurlMultiHandle); | 786 | LLHTTPAssetRequest *new_req = new LLHTTPAssetRequest(this, req->getUUID(), |
583 | new_req->mIsLocalUpload = TRUE; | 787 | req->getType(), RT_LOCALUPLOAD, tmp_url, mCurlMultiHandle); |
584 | new_req->mRequestingAgentID = req->mRequestingAgentID; | 788 | new_req->mRequestingAgentID = req->mRequestingAgentID; |
585 | 789 | ||
586 | // Sets pending upload flag internally | 790 | // Sets pending upload flag internally |
@@ -591,13 +795,22 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
591 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READFUNCTION, &curlUpCallback); | 795 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READFUNCTION, &curlUpCallback); |
592 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READDATA, new_req->mCurlHandle); | 796 | curl_easy_setopt(new_req->mCurlHandle, CURLOPT_READDATA, new_req->mCurlHandle); |
593 | 797 | ||
594 | curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); | 798 | mcode = curl_multi_add_handle(mCurlMultiHandle, new_req->mCurlHandle); |
595 | llinfos << "TAT: LLHTTPAssetStorage::checkForTimeouts() : pending local!" | 799 | if (mcode > CURLM_OK) |
596 | << " Requesting PUT " << new_req->mURLBuffer << llendl; | 800 | { |
801 | // Failure. Deleting the pending request will remove it from the running | ||
802 | // queue, and push it to the end of the pending queue. | ||
803 | deletePendingRequest(RT_LOCALUPLOAD, req->getType(), req->getUUID()); | ||
804 | break; | ||
805 | } | ||
806 | else | ||
807 | { | ||
808 | llinfos << "TAT: LLHTTPAssetStorage::checkForTimeouts() : pending local!" | ||
809 | << " Requesting PUT " << new_req->mURLBuffer << llendl; | ||
810 | } | ||
597 | // Pending upload will have been flagged by the request | 811 | // Pending upload will have been flagged by the request |
598 | } | 812 | } |
599 | S32 count = 0; | 813 | S32 count = 0; |
600 | CURLMcode mcode; | ||
601 | int queue_length; | 814 | int queue_length; |
602 | do | 815 | do |
603 | { | 816 | { |
@@ -618,12 +831,15 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
618 | curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_PRIVATE, &req); | 831 | curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_PRIVATE, &req); |
619 | 832 | ||
620 | curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_HTTP_CODE, &curl_result); | 833 | curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_HTTP_CODE, &curl_result); |
621 | if (req->mIsUpload || req->mIsLocalUpload) | 834 | if (RT_UPLOAD == req->mRequestType || RT_LOCALUPLOAD == req->mRequestType) |
622 | { | 835 | { |
623 | if (curl_msg->data.result == CURLE_OK && (curl_result == HTTP_OK || curl_result == HTTP_PUT_OK || curl_result == HTTP_NO_CONTENT)) | 836 | if (curl_msg->data.result == CURLE_OK && |
837 | ( curl_result == HTTP_OK | ||
838 | || curl_result == HTTP_PUT_OK | ||
839 | || curl_result == HTTP_NO_CONTENT)) | ||
624 | { | 840 | { |
625 | llinfos << "Success uploading " << req->getUUID() << " to " << req->mURLBuffer << llendl; | 841 | llinfos << "Success uploading " << req->getUUID() << " to " << req->mURLBuffer << llendl; |
626 | if (req->mIsLocalUpload) | 842 | if (RT_LOCALUPLOAD == req->mRequestType) |
627 | { | 843 | { |
628 | addTempAssetData(req->getUUID(), req->mRequestingAgentID, mHostName); | 844 | addTempAssetData(req->getUUID(), req->mRequestingAgentID, mHostName); |
629 | } | 845 | } |
@@ -655,7 +871,7 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
655 | // Pending upload flag will get cleared when the request is deleted | 871 | // Pending upload flag will get cleared when the request is deleted |
656 | } | 872 | } |
657 | } | 873 | } |
658 | else if (req->mIsDownload) | 874 | else if (RT_DOWNLOAD == req->mRequestType) |
659 | { | 875 | { |
660 | if (curl_result == HTTP_OK && curl_msg->data.result == CURLE_OK) | 876 | if (curl_result == HTTP_OK && curl_msg->data.result == CURLE_OK) |
661 | { | 877 | { |
@@ -667,7 +883,7 @@ void LLHTTPAssetStorage::checkForTimeouts() | |||
667 | } | 883 | } |
668 | else | 884 | else |
669 | { | 885 | { |
670 | // TODO: if this actually indicates a bad asset on the server | 886 | // *TODO: if this actually indicates a bad asset on the server |
671 | // (not certain at this point), then delete it | 887 | // (not certain at this point), then delete it |
672 | llwarns << "Found " << req->mURLBuffer << " to be zero size" << llendl; | 888 | llwarns << "Found " << req->mURLBuffer << " to be zero size" << llendl; |
673 | xfer_result = LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE; | 889 | xfer_result = LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE; |
@@ -793,9 +1009,8 @@ S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asse | |||
793 | } | 1009 | } |
794 | 1010 | ||
795 | // make sure we use the normal curl setup, even though we don't really need a request object | 1011 | // make sure we use the normal curl setup, even though we don't really need a request object |
796 | LLHTTPAssetRequest req(this, uuid, asset_type, url.c_str(), mCurlMultiHandle); | 1012 | LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url.c_str(), mCurlMultiHandle); |
797 | req.mFP = fp; | 1013 | req.mFP = fp; |
798 | req.mIsDownload = TRUE; | ||
799 | 1014 | ||
800 | req.setupCurlHandle(); | 1015 | req.setupCurlHandle(); |
801 | curl_easy_setopt(req.mCurlHandle, CURLOPT_FOLLOWLOCATION, TRUE); | 1016 | curl_easy_setopt(req.mCurlHandle, CURLOPT_FOLLOWLOCATION, TRUE); |
@@ -887,6 +1102,63 @@ size_t LLHTTPAssetStorage::curlFileDownCallback(void *data, size_t size, size_t | |||
887 | return fwrite(data, size, nmemb, req->mFP); | 1102 | return fwrite(data, size, nmemb, req->mFP); |
888 | } | 1103 | } |
889 | 1104 | ||
1105 | LLAssetStorage::request_list_t* LLHTTPAssetStorage::getRunningList(LLAssetStorage::ERequestType rt) | ||
1106 | { | ||
1107 | switch (rt) | ||
1108 | { | ||
1109 | case RT_DOWNLOAD: | ||
1110 | return &mRunningDownloads; | ||
1111 | case RT_UPLOAD: | ||
1112 | return &mRunningUploads; | ||
1113 | case RT_LOCALUPLOAD: | ||
1114 | return &mRunningLocalUploads; | ||
1115 | default: | ||
1116 | return NULL; | ||
1117 | } | ||
1118 | } | ||
1119 | |||
1120 | const LLAssetStorage::request_list_t* LLHTTPAssetStorage::getRunningList(LLAssetStorage::ERequestType rt) const | ||
1121 | { | ||
1122 | switch (rt) | ||
1123 | { | ||
1124 | case RT_DOWNLOAD: | ||
1125 | return &mRunningDownloads; | ||
1126 | case RT_UPLOAD: | ||
1127 | return &mRunningUploads; | ||
1128 | case RT_LOCALUPLOAD: | ||
1129 | return &mRunningLocalUploads; | ||
1130 | default: | ||
1131 | return NULL; | ||
1132 | } | ||
1133 | } | ||
1134 | |||
1135 | |||
1136 | void LLHTTPAssetStorage::addRunningRequest(ERequestType rt, LLHTTPAssetRequest* request) | ||
1137 | { | ||
1138 | request_list_t* requests = getRunningList(rt); | ||
1139 | if (requests) | ||
1140 | { | ||
1141 | requests->push_back(request); | ||
1142 | } | ||
1143 | else | ||
1144 | { | ||
1145 | llerrs << "LLHTTPAssetStorage::addRunningRequest - Request is not an upload OR download, this is bad!" << llendl; | ||
1146 | } | ||
1147 | } | ||
1148 | |||
1149 | void LLHTTPAssetStorage::removeRunningRequest(ERequestType rt, LLHTTPAssetRequest* request) | ||
1150 | { | ||
1151 | request_list_t* requests = getRunningList(rt); | ||
1152 | if (requests) | ||
1153 | { | ||
1154 | requests->remove(request); | ||
1155 | } | ||
1156 | else | ||
1157 | { | ||
1158 | llerrs << "LLHTTPAssetStorage::removeRunningRequest - Destroyed request is not an upload OR download, this is bad!" << llendl; | ||
1159 | } | ||
1160 | } | ||
1161 | |||
890 | // virtual | 1162 | // virtual |
891 | void LLHTTPAssetStorage::addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name) | 1163 | void LLHTTPAssetStorage::addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name) |
892 | { | 1164 | { |
diff --git a/linden/indra/llmessage/llhttpassetstorage.h b/linden/indra/llmessage/llhttpassetstorage.h index d09e2ce..d98af45 100644 --- a/linden/indra/llmessage/llhttpassetstorage.h +++ b/linden/indra/llmessage/llhttpassetstorage.h | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "curl/curl.h" | 32 | #include "curl/curl.h" |
33 | 33 | ||
34 | class LLVFile; | 34 | class LLVFile; |
35 | class LLHTTPAssetRequest; | ||
35 | typedef void (*progress_callback)(void* userdata); | 36 | typedef void (*progress_callback)(void* userdata); |
36 | 37 | ||
37 | struct LLTempAssetData; | 38 | struct LLTempAssetData; |
@@ -75,11 +76,25 @@ public: | |||
75 | bool temp_file, | 76 | bool temp_file, |
76 | bool is_priority); | 77 | bool is_priority); |
77 | 78 | ||
79 | virtual LLSD getPendingDetails(ERequestType rt, | ||
80 | LLAssetType::EType asset_type, | ||
81 | const std::string& detail_prefix) const; | ||
82 | |||
83 | virtual LLSD getPendingRequest(ERequestType rt, | ||
84 | LLAssetType::EType asset_type, | ||
85 | const LLUUID& asset_id) const; | ||
86 | |||
87 | virtual bool deletePendingRequest(ERequestType rt, | ||
88 | LLAssetType::EType asset_type, | ||
89 | const LLUUID& asset_id); | ||
90 | |||
78 | // Hack. One off curl download an URL to a file. Probably should be elsewhere. | 91 | // Hack. One off curl download an URL to a file. Probably should be elsewhere. |
79 | // Only used by lldynamicstate. The API is broken, and should be replaced with | 92 | // Only used by lldynamicstate. The API is broken, and should be replaced with |
80 | // a generic HTTP file fetch - Doug 9/25/06 | 93 | // a generic HTTP file fetch - Doug 9/25/06 |
81 | S32 getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata); | 94 | S32 getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata); |
82 | 95 | ||
96 | LLAssetRequest* findNextRequest(request_list_t& pending, request_list_t& running); | ||
97 | |||
83 | void checkForTimeouts(); | 98 | void checkForTimeouts(); |
84 | 99 | ||
85 | static size_t curlDownCallback(void *data, size_t size, size_t nmemb, void *user_data); | 100 | static size_t curlDownCallback(void *data, size_t size, size_t nmemb, void *user_data); |
@@ -88,12 +103,11 @@ public: | |||
88 | static size_t nullOutputCallback(void *data, size_t size, size_t nmemb, void *user_data); | 103 | static size_t nullOutputCallback(void *data, size_t size, size_t nmemb, void *user_data); |
89 | 104 | ||
90 | // Should only be used by the LLHTTPAssetRequest | 105 | // Should only be used by the LLHTTPAssetRequest |
91 | void setPendingUpload() { mPendingUpload = TRUE; } | 106 | void addRunningRequest(ERequestType rt, LLHTTPAssetRequest* request); |
92 | void setPendingLocalUpload() { mPendingLocalUpload = TRUE; } | 107 | void removeRunningRequest(ERequestType rt, LLHTTPAssetRequest* request); |
93 | void setPendingDownload() { mPendingDownload = TRUE; } | 108 | |
94 | void clearPendingUpload() { mPendingUpload = FALSE; } | 109 | request_list_t* getRunningList(ERequestType rt); |
95 | void clearPendingLocalUpload() { mPendingLocalUpload = FALSE; } | 110 | const request_list_t* getRunningList(ERequestType rt) const; |
96 | void clearPendingDownload() { mPendingDownload = FALSE; } | ||
97 | 111 | ||
98 | // Temp assets are stored on sim nodes, they have agent ID and location data associated with them. | 112 | // Temp assets are stored on sim nodes, they have agent ID and location data associated with them. |
99 | virtual void addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name); | 113 | virtual void addTempAssetData(const LLUUID& asset_id, const LLUUID& agent_id, const std::string& host_name); |
@@ -125,9 +139,9 @@ protected: | |||
125 | 139 | ||
126 | CURLM *mCurlMultiHandle; | 140 | CURLM *mCurlMultiHandle; |
127 | 141 | ||
128 | BOOL mPendingDownload; | 142 | request_list_t mRunningDownloads; |
129 | BOOL mPendingUpload; | 143 | request_list_t mRunningUploads; |
130 | BOOL mPendingLocalUpload; | 144 | request_list_t mRunningLocalUploads; |
131 | 145 | ||
132 | uuid_tempdata_map mTempAssets; | 146 | uuid_tempdata_map mTempAssets; |
133 | }; | 147 | }; |
diff --git a/linden/indra/llmessage/llhttpclient.cpp b/linden/indra/llmessage/llhttpclient.cpp index d94918e..3755ae0 100644 --- a/linden/indra/llmessage/llhttpclient.cpp +++ b/linden/indra/llmessage/llhttpclient.cpp | |||
@@ -37,6 +37,8 @@ | |||
37 | #include "llvfile.h" | 37 | #include "llvfile.h" |
38 | #include "llvfs.h" | 38 | #include "llvfs.h" |
39 | 39 | ||
40 | #include <curl/curl.h> | ||
41 | |||
40 | static const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; | 42 | static const F32 HTTP_REQUEST_EXPIRY_SECS = 60.0f; |
41 | 43 | ||
42 | static std::string gCABundle; | 44 | static std::string gCABundle; |
@@ -148,6 +150,27 @@ namespace | |||
148 | 150 | ||
149 | const LLSD mSD; | 151 | const LLSD mSD; |
150 | }; | 152 | }; |
153 | |||
154 | class RawInjector : public Injector | ||
155 | { | ||
156 | public: | ||
157 | RawInjector(const U8* data, S32 size) : mData(data), mSize(size) {} | ||
158 | virtual ~RawInjector() {} | ||
159 | |||
160 | const char* contentType() { return "application/octet-stream"; } | ||
161 | |||
162 | virtual EStatus process_impl(const LLChannelDescriptors& channels, | ||
163 | buffer_ptr_t& buffer, bool& eos, LLSD& context, LLPumpIO* pump) | ||
164 | { | ||
165 | LLBufferStream ostream(channels, buffer.get()); | ||
166 | ostream.write((const char *)mData, mSize); // hopefully chars are always U8s | ||
167 | eos = true; | ||
168 | return STATUS_DONE; | ||
169 | } | ||
170 | |||
171 | const U8* mData; | ||
172 | S32 mSize; | ||
173 | }; | ||
151 | 174 | ||
152 | class FileInjector : public Injector | 175 | class FileInjector : public Injector |
153 | { | 176 | { |
@@ -243,6 +266,84 @@ void LLHTTPClient::get(const std::string& url, ResponderPtr responder) | |||
243 | request(url, LLURLRequest::HTTP_GET, NULL, responder); | 266 | request(url, LLURLRequest::HTTP_GET, NULL, responder); |
244 | } | 267 | } |
245 | 268 | ||
269 | // A simple class for managing data returned from a curl http request. | ||
270 | class LLHTTPBuffer | ||
271 | { | ||
272 | public: | ||
273 | LLHTTPBuffer() { } | ||
274 | |||
275 | static size_t curl_write( void *ptr, size_t size, size_t nmemb, void *user_data) | ||
276 | { | ||
277 | LLHTTPBuffer* self = (LLHTTPBuffer*)user_data; | ||
278 | |||
279 | size_t bytes = (size * nmemb); | ||
280 | self->mBuffer.append((char*)ptr,bytes); | ||
281 | return nmemb; | ||
282 | } | ||
283 | |||
284 | LLSD asLLSD() | ||
285 | { | ||
286 | LLSD content; | ||
287 | |||
288 | if (mBuffer.empty()) return content; | ||
289 | |||
290 | std::istringstream istr(mBuffer); | ||
291 | LLSDSerialize::fromXML(content, istr); | ||
292 | return content; | ||
293 | } | ||
294 | |||
295 | std::string asString() | ||
296 | { | ||
297 | return mBuffer; | ||
298 | } | ||
299 | |||
300 | private: | ||
301 | std::string mBuffer; | ||
302 | }; | ||
303 | |||
304 | // This call is blocking! This is probably usually bad. :( | ||
305 | LLSD LLHTTPClient::blockingGet(const std::string& url) | ||
306 | { | ||
307 | llinfos << "blockingGet of " << url << llendl; | ||
308 | |||
309 | // Returns an LLSD map: {status: integer, body: map} | ||
310 | char curl_error_buffer[CURL_ERROR_SIZE]; | ||
311 | CURL* curlp = curl_easy_init(); | ||
312 | |||
313 | LLHTTPBuffer http_buffer; | ||
314 | |||
315 | curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, LLHTTPBuffer::curl_write); | ||
316 | curl_easy_setopt(curlp, CURLOPT_WRITEDATA, &http_buffer); | ||
317 | curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); | ||
318 | curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curl_error_buffer); | ||
319 | curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); | ||
320 | |||
321 | LLSD response = LLSD::emptyMap(); | ||
322 | |||
323 | S32 curl_success = curl_easy_perform(curlp); | ||
324 | |||
325 | S32 http_status = 499; | ||
326 | curl_easy_getinfo(curlp,CURLINFO_RESPONSE_CODE, &http_status); | ||
327 | |||
328 | response["status"] = http_status; | ||
329 | |||
330 | if (curl_success != 0 | ||
331 | && http_status != 404) // We expect 404s, don't spam for them. | ||
332 | { | ||
333 | llwarns << "CURL ERROR: " << curl_error_buffer << llendl; | ||
334 | |||
335 | response["body"] = http_buffer.asString(); | ||
336 | } | ||
337 | else | ||
338 | { | ||
339 | response["body"] = http_buffer.asLLSD(); | ||
340 | } | ||
341 | |||
342 | curl_easy_cleanup(curlp); | ||
343 | |||
344 | return response; | ||
345 | } | ||
346 | |||
246 | void LLHTTPClient::put(const std::string& url, const LLSD& body, ResponderPtr responder) | 347 | void LLHTTPClient::put(const std::string& url, const LLSD& body, ResponderPtr responder) |
247 | { | 348 | { |
248 | request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder); | 349 | request(url, LLURLRequest::HTTP_PUT, new LLSDInjector(body), responder); |
@@ -253,6 +354,11 @@ void LLHTTPClient::post(const std::string& url, const LLSD& body, ResponderPtr r | |||
253 | request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder); | 354 | request(url, LLURLRequest::HTTP_POST, new LLSDInjector(body), responder); |
254 | } | 355 | } |
255 | 356 | ||
357 | void LLHTTPClient::post(const std::string& url, const U8* data, S32 size, ResponderPtr responder) | ||
358 | { | ||
359 | request(url, LLURLRequest::HTTP_POST, new RawInjector(data, size), responder); | ||
360 | } | ||
361 | |||
256 | void LLHTTPClient::del(const std::string& url, ResponderPtr responder) | 362 | void LLHTTPClient::del(const std::string& url, ResponderPtr responder) |
257 | { | 363 | { |
258 | request(url, LLURLRequest::HTTP_DELETE, NULL, responder); | 364 | request(url, LLURLRequest::HTTP_DELETE, NULL, responder); |
@@ -301,4 +407,3 @@ namespace boost | |||
301 | } | 407 | } |
302 | } | 408 | } |
303 | }; | 409 | }; |
304 | |||
diff --git a/linden/indra/llmessage/llhttpclient.h b/linden/indra/llmessage/llhttpclient.h index d48d084..93859eb 100644 --- a/linden/indra/llmessage/llhttpclient.h +++ b/linden/indra/llmessage/llhttpclient.h | |||
@@ -73,10 +73,14 @@ public: | |||
73 | static void put(const std::string& url, const LLSD& body, ResponderPtr); | 73 | static void put(const std::string& url, const LLSD& body, ResponderPtr); |
74 | ///< non-blocking | 74 | ///< non-blocking |
75 | static void post(const std::string& url, const LLSD& body, ResponderPtr); | 75 | static void post(const std::string& url, const LLSD& body, ResponderPtr); |
76 | static void post(const std::string& url, const U8* data, S32 size, ResponderPtr responder); | ||
76 | static void postFile(const std::string& url, const std::string& filename, ResponderPtr); | 77 | static void postFile(const std::string& url, const std::string& filename, ResponderPtr); |
77 | static void postFile(const std::string& url, const LLUUID& uuid, | 78 | static void postFile(const std::string& url, const LLUUID& uuid, |
78 | LLAssetType::EType asset_type, ResponderPtr responder); | 79 | LLAssetType::EType asset_type, ResponderPtr responder); |
79 | 80 | ||
81 | // Blocking HTTP get that returns an LLSD map of status and body. | ||
82 | static LLSD blockingGet(const std::string& url); | ||
83 | |||
80 | static void del(const std::string& url, ResponderPtr); | 84 | static void del(const std::string& url, ResponderPtr); |
81 | ///< sends a DELETE method, but we can't call it delete in c++ | 85 | ///< sends a DELETE method, but we can't call it delete in c++ |
82 | 86 | ||
diff --git a/linden/indra/llmessage/llinstantmessage.cpp b/linden/indra/llmessage/llinstantmessage.cpp index f1f4514..6f6e022 100644 --- a/linden/indra/llmessage/llinstantmessage.cpp +++ b/linden/indra/llmessage/llinstantmessage.cpp | |||
@@ -226,8 +226,8 @@ void pack_instant_message_block( | |||
226 | S32 bytes_left = MTUBYTES; | 226 | S32 bytes_left = MTUBYTES; |
227 | if(message) | 227 | if(message) |
228 | { | 228 | { |
229 | char buffer[MTUBYTES]; | 229 | char buffer[MTUBYTES]; /*Flawfinder: ignore*/ |
230 | bytes_left -= snprintf(buffer, MTUBYTES, "%s", message); | 230 | bytes_left -= snprintf(buffer, MTUBYTES, "%s", message); /*Flawfinder: ignore*/ |
231 | bytes_left = llmax(0, bytes_left); | 231 | bytes_left = llmax(0, bytes_left); |
232 | msg->addStringFast(_PREHASH_Message, buffer); | 232 | msg->addStringFast(_PREHASH_Message, buffer); |
233 | } | 233 | } |
@@ -263,11 +263,11 @@ void LLIMInfo::unpackMessageBlock(LLMessageSystem* msg) | |||
263 | mIMType = (EInstantMessage) dialog; | 263 | mIMType = (EInstantMessage) dialog; |
264 | msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, mID); | 264 | msg->getUUIDFast(_PREHASH_MessageBlock, _PREHASH_ID, mID); |
265 | msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_Timestamp, mTimeStamp); | 265 | msg->getU32Fast(_PREHASH_MessageBlock, _PREHASH_Timestamp, mTimeStamp); |
266 | char name[DB_FULL_NAME_BUF_SIZE]; | 266 | char name[DB_FULL_NAME_BUF_SIZE]; /*Flawfinder: ignore*/ |
267 | msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, DB_FULL_NAME_BUF_SIZE, name); | 267 | msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_FromAgentName, DB_FULL_NAME_BUF_SIZE, name); |
268 | mName.assign(name); | 268 | mName.assign(name); |
269 | 269 | ||
270 | char message[DB_IM_MSG_BUF_SIZE]; | 270 | char message[DB_IM_MSG_BUF_SIZE]; /*Flawfinder: ignore*/ |
271 | msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, DB_IM_MSG_BUF_SIZE, message); | 271 | msg->getStringFast(_PREHASH_MessageBlock, _PREHASH_Message, DB_IM_MSG_BUF_SIZE, message); |
272 | mMessage.assign(message); | 272 | mMessage.assign(message); |
273 | 273 | ||
diff --git a/linden/indra/llmessage/llmail.cpp b/linden/indra/llmessage/llmail.cpp index e84d097..aea3689 100644 --- a/linden/indra/llmessage/llmail.cpp +++ b/linden/indra/llmessage/llmail.cpp | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | #include "linden_common.h" | 28 | #include "linden_common.h" |
29 | 29 | ||
30 | #include "llmail.h" | ||
31 | |||
30 | // APR on Windows needs full windows headers | 32 | // APR on Windows needs full windows headers |
31 | #ifdef LL_WINDOWS | 33 | #ifdef LL_WINDOWS |
32 | # undef WIN32_LEAN_AND_MEAN | 34 | # undef WIN32_LEAN_AND_MEAN |
@@ -38,14 +40,16 @@ | |||
38 | #include <sstream> | 40 | #include <sstream> |
39 | #include <boost/regex.hpp> | 41 | #include <boost/regex.hpp> |
40 | 42 | ||
41 | #include "llmail.h" | ||
42 | |||
43 | #include "apr-1/apr_pools.h" | 43 | #include "apr-1/apr_pools.h" |
44 | #include "apr-1/apr_network_io.h" | 44 | #include "apr-1/apr_network_io.h" |
45 | 45 | ||
46 | #include "llapr.h" | 46 | #include "llapr.h" |
47 | #include "llbase32.h" // IM-to-email address | ||
48 | #include "llblowfishcipher.h" | ||
47 | #include "llerror.h" | 49 | #include "llerror.h" |
48 | #include "llhost.h" | 50 | #include "llhost.h" |
51 | #include "llstring.h" | ||
52 | #include "lluuid.h" | ||
49 | #include "net.h" | 53 | #include "net.h" |
50 | 54 | ||
51 | // | 55 | // |
@@ -105,11 +109,12 @@ void disconnect_smtp() | |||
105 | 109 | ||
106 | // Returns TRUE on success. | 110 | // Returns TRUE on success. |
107 | // message should NOT be SMTP escaped. | 111 | // message should NOT be SMTP escaped. |
108 | BOOL send_mail(const char* from_name, const char* from_address, | 112 | // static |
113 | BOOL LLMail::send(const char* from_name, const char* from_address, | ||
109 | const char* to_name, const char* to_address, | 114 | const char* to_name, const char* to_address, |
110 | const char* subject, const char* message) | 115 | const char* subject, const char* message) |
111 | { | 116 | { |
112 | std::string header = build_smtp_transaction( | 117 | std::string header = buildSMTPTransaction( |
113 | from_name, | 118 | from_name, |
114 | from_address, | 119 | from_address, |
115 | to_name, | 120 | to_name, |
@@ -125,12 +130,13 @@ BOOL send_mail(const char* from_name, const char* from_address, | |||
125 | { | 130 | { |
126 | message_str = message; | 131 | message_str = message; |
127 | } | 132 | } |
128 | bool rv = send_mail(header, message_str, to_address, from_address); | 133 | bool rv = send(header, message_str, to_address, from_address); |
129 | if(rv) return TRUE; | 134 | if(rv) return TRUE; |
130 | return FALSE; | 135 | return FALSE; |
131 | } | 136 | } |
132 | 137 | ||
133 | void init_mail(const std::string& hostname, apr_pool_t* pool) | 138 | // static |
139 | void LLMail::init(const std::string& hostname, apr_pool_t* pool) | ||
134 | { | 140 | { |
135 | gMailSocket = NULL; | 141 | gMailSocket = NULL; |
136 | if(hostname.empty() || !pool) | 142 | if(hostname.empty() || !pool) |
@@ -157,12 +163,14 @@ void init_mail(const std::string& hostname, apr_pool_t* pool) | |||
157 | } | 163 | } |
158 | } | 164 | } |
159 | 165 | ||
160 | void enable_mail(bool mail_enabled) | 166 | // static |
167 | void LLMail::enable(bool mail_enabled) | ||
161 | { | 168 | { |
162 | gMailEnabled = mail_enabled; | 169 | gMailEnabled = mail_enabled; |
163 | } | 170 | } |
164 | 171 | ||
165 | std::string build_smtp_transaction( | 172 | // static |
173 | std::string LLMail::buildSMTPTransaction( | ||
166 | const char* from_name, | 174 | const char* from_name, |
167 | const char* from_address, | 175 | const char* from_address, |
168 | const char* to_name, | 176 | const char* to_name, |
@@ -216,7 +224,8 @@ std::string build_smtp_transaction( | |||
216 | return header.str(); | 224 | return header.str(); |
217 | } | 225 | } |
218 | 226 | ||
219 | bool send_mail( | 227 | // static |
228 | bool LLMail::send( | ||
220 | const std::string& header, | 229 | const std::string& header, |
221 | const std::string& message, | 230 | const std::string& message, |
222 | const char* from_address, | 231 | const char* from_address, |
@@ -309,3 +318,40 @@ bool send_mail( | |||
309 | #endif | 318 | #endif |
310 | return true; | 319 | return true; |
311 | } | 320 | } |
321 | |||
322 | |||
323 | // static | ||
324 | std::string LLMail::encryptIMEmailAddress(const LLUUID& from_agent_id, | ||
325 | const LLUUID& to_agent_id, | ||
326 | U32 time, | ||
327 | const U8* secret, | ||
328 | size_t secret_size) | ||
329 | { | ||
330 | #if LL_WINDOWS | ||
331 | return "blowfish-not-supported-on-windows"; | ||
332 | #else | ||
333 | size_t data_size = 4 + UUID_BYTES + UUID_BYTES; | ||
334 | // Convert input data into a binary blob | ||
335 | std::vector<U8> data; | ||
336 | data.resize(data_size); | ||
337 | // *NOTE: This may suffer from endian issues. Could be htonmemcpy. | ||
338 | memcpy(&data[0], &time, 4); | ||
339 | memcpy(&data[4], &from_agent_id.mData[0], UUID_BYTES); | ||
340 | memcpy(&data[4 + UUID_BYTES], &to_agent_id.mData[0], UUID_BYTES); | ||
341 | |||
342 | // Encrypt the blob | ||
343 | LLBlowfishCipher cipher(secret, secret_size); | ||
344 | size_t encrypted_size = cipher.requiredEncryptionSpace(data.size()); | ||
345 | U8* encrypted = new U8[encrypted_size]; | ||
346 | cipher.encrypt(&data[0], data_size, encrypted, encrypted_size); | ||
347 | |||
348 | std::string address = LLBase32::encode(encrypted, encrypted_size); | ||
349 | |||
350 | // Make it more pretty for humans. | ||
351 | LLString::toLower(address); | ||
352 | |||
353 | delete [] encrypted; | ||
354 | |||
355 | return address; | ||
356 | #endif | ||
357 | } | ||
diff --git a/linden/indra/llmessage/llmail.h b/linden/indra/llmessage/llmail.h index 82c272f..b1dc3b5 100644 --- a/linden/indra/llmessage/llmail.h +++ b/linden/indra/llmessage/llmail.h | |||
@@ -30,55 +30,84 @@ | |||
30 | 30 | ||
31 | typedef struct apr_pool_t apr_pool_t; | 31 | typedef struct apr_pool_t apr_pool_t; |
32 | 32 | ||
33 | // if hostname is NULL, then the host is resolved as 'mail' | 33 | class LLUUID; |
34 | void init_mail(const std::string& hostname, apr_pool_t* pool); | ||
35 | 34 | ||
36 | // Allow all email transmission to be disabled/enabled. | 35 | class LLMail |
37 | void enable_mail(bool mail_enabled); | 36 | { |
37 | public: | ||
38 | // if hostname is NULL, then the host is resolved as 'mail' | ||
39 | static void init(const std::string& hostname, apr_pool_t* pool); | ||
38 | 40 | ||
39 | // returns TRUE if the call succeeds, FALSE otherwise. | 41 | // Allow all email transmission to be disabled/enabled. |
40 | // | 42 | static void enable(bool mail_enabled); |
41 | // Results in: | ||
42 | // From: "from_name" <from_address> | ||
43 | // To: "to_name" <to_address> | ||
44 | // Subject: subject | ||
45 | // message | ||
46 | BOOL send_mail(const char* from_name, const char* from_address, | ||
47 | const char* to_name, const char* to_address, | ||
48 | const char* subject, const char* message); | ||
49 | 43 | ||
50 | /** | 44 | // returns TRUE if the call succeeds, FALSE otherwise. |
51 | * @brief build the complete smtp transaction & header for use in an | 45 | // |
52 | * mail. | 46 | // Results in: |
53 | * | 47 | // From: "from_name" <from_address> |
54 | * @param from_name The name of the email sender | 48 | // To: "to_name" <to_address> |
55 | * @param from_address The email address for the sender | 49 | // Subject: subject |
56 | * @param to_name The name of the email recipient | 50 | // message |
57 | * @param to_name The email recipient address | 51 | static BOOL send(const char* from_name, const char* from_address, |
58 | * @param subject The subject of the email | 52 | const char* to_name, const char* to_address, |
59 | * @return Returns the complete SMTP transaction mail header. | 53 | const char* subject, const char* message); |
60 | */ | ||
61 | std::string build_smtp_transaction( | ||
62 | const char* from_name, | ||
63 | const char* from_address, | ||
64 | const char* to_name, | ||
65 | const char* to_address, | ||
66 | const char* subject); | ||
67 | 54 | ||
68 | /** | 55 | /** |
69 | * @brief send an email with header and body. | 56 | * @brief build the complete smtp transaction & header for use in an |
70 | * | 57 | * mail. |
71 | * @param header The email header. Use build_mail_header(). | 58 | * |
72 | * @param message The unescaped email message. | 59 | * @param from_name The name of the email sender |
73 | * @param from_address Used for debugging | 60 | * @param from_address The email address for the sender |
74 | * @param to_address Used for debugging | 61 | * @param to_name The name of the email recipient |
75 | * @return Returns true if the message could be sent. | 62 | * @param to_name The email recipient address |
76 | */ | 63 | * @param subject The subject of the email |
77 | bool send_mail( | 64 | * @return Returns the complete SMTP transaction mail header. |
78 | const std::string& header, | 65 | */ |
79 | const std::string& message, | 66 | static std::string buildSMTPTransaction( |
80 | const char* from_address, | 67 | const char* from_name, |
81 | const char* to_address); | 68 | const char* from_address, |
69 | const char* to_name, | ||
70 | const char* to_address, | ||
71 | const char* subject); | ||
72 | |||
73 | /** | ||
74 | * @brief send an email with header and body. | ||
75 | * | ||
76 | * @param header The email header. Use build_mail_header(). | ||
77 | * @param message The unescaped email message. | ||
78 | * @param from_address Used for debugging | ||
79 | * @param to_address Used for debugging | ||
80 | * @return Returns true if the message could be sent. | ||
81 | */ | ||
82 | static bool send( | ||
83 | const std::string& header, | ||
84 | const std::string& message, | ||
85 | const char* from_address, | ||
86 | const char* to_address); | ||
87 | |||
88 | // IM-to-email sessions use a "session id" based on an encrypted | ||
89 | // combination of from agent_id, to agent_id, and timestamp. When | ||
90 | // a user replies to an email we use the from_id to determine the | ||
91 | // sender's name and the to_id to route the message. The address | ||
92 | // is encrypted to prevent users from building addresses to spoof | ||
93 | // IMs from other users. The timestamps allow the "sessions" to | ||
94 | // expire, in case one of the sessions is stolen/hijacked. | ||
95 | // | ||
96 | // indra/tools/mailglue is responsible for parsing the inbound mail. | ||
97 | // | ||
98 | // secret: binary blob passed to blowfish, max length 56 bytes | ||
99 | // secret_size: length of blob, in bytes | ||
100 | // | ||
101 | // Returns: "base64" encoded email local-part, with _ and - as the | ||
102 | // non-alphanumeric characters. This allows better compatibility | ||
103 | // with email systems than the default / and + extra chars. JC | ||
104 | static std::string encryptIMEmailAddress( | ||
105 | const LLUUID& from_agent_id, | ||
106 | const LLUUID& to_agent_id, | ||
107 | U32 time, | ||
108 | const U8* secret, | ||
109 | size_t secret_size); | ||
110 | }; | ||
82 | 111 | ||
83 | extern const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE; | 112 | extern const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE; |
84 | 113 | ||
diff --git a/linden/indra/llmessage/llmessage.vcproj b/linden/indra/llmessage/llmessage.vcproj index 3043ee5..11f4dbf 100644 --- a/linden/indra/llmessage/llmessage.vcproj +++ b/linden/indra/llmessage/llmessage.vcproj | |||
@@ -153,6 +153,9 @@ | |||
153 | RelativePath=".\llassetstorage.cpp"> | 153 | RelativePath=".\llassetstorage.cpp"> |
154 | </File> | 154 | </File> |
155 | <File | 155 | <File |
156 | RelativePath=".\llblowfishcipher.cpp"> | ||
157 | </File> | ||
158 | <File | ||
156 | RelativePath=".\llbuffer.cpp"> | 159 | RelativePath=".\llbuffer.cpp"> |
157 | </File> | 160 | </File> |
158 | <File | 161 | <File |
@@ -171,6 +174,9 @@ | |||
171 | RelativePath=".\llclassifiedflags.cpp"> | 174 | RelativePath=".\llclassifiedflags.cpp"> |
172 | </File> | 175 | </File> |
173 | <File | 176 | <File |
177 | RelativePath=".\llcurl.cpp"> | ||
178 | </File> | ||
179 | <File | ||
174 | RelativePath=".\lldatapacker.cpp"> | 180 | RelativePath=".\lldatapacker.cpp"> |
175 | </File> | 181 | </File> |
176 | <File | 182 | <File |
@@ -344,6 +350,9 @@ | |||
344 | RelativePath=".\llassetstorage.h"> | 350 | RelativePath=".\llassetstorage.h"> |
345 | </File> | 351 | </File> |
346 | <File | 352 | <File |
353 | RelativePath=".\llblowfishcipher.h"> | ||
354 | </File> | ||
355 | <File | ||
347 | RelativePath=".\llbuffer.h"> | 356 | RelativePath=".\llbuffer.h"> |
348 | </File> | 357 | </File> |
349 | <File | 358 | <File |
@@ -362,6 +371,9 @@ | |||
362 | RelativePath=".\llchainio.h"> | 371 | RelativePath=".\llchainio.h"> |
363 | </File> | 372 | </File> |
364 | <File | 373 | <File |
374 | RelativePath=".\llcipher.h"> | ||
375 | </File> | ||
376 | <File | ||
365 | RelativePath=".\llcircuit.h"> | 377 | RelativePath=".\llcircuit.h"> |
366 | </File> | 378 | </File> |
367 | <File | 379 | <File |
@@ -371,7 +383,7 @@ | |||
371 | RelativePath=".\llcoordframe.h"> | 383 | RelativePath=".\llcoordframe.h"> |
372 | </File> | 384 | </File> |
373 | <File | 385 | <File |
374 | RelativePath=".\llcrypto.h"> | 386 | RelativePath=".\llcurl.h"> |
375 | </File> | 387 | </File> |
376 | <File | 388 | <File |
377 | RelativePath=".\lldatapacker.h"> | 389 | RelativePath=".\lldatapacker.h"> |
@@ -440,6 +452,9 @@ | |||
440 | RelativePath=".\llnamevalue.h"> | 452 | RelativePath=".\llnamevalue.h"> |
441 | </File> | 453 | </File> |
442 | <File | 454 | <File |
455 | RelativePath=".\llnullcipher.h"> | ||
456 | </File> | ||
457 | <File | ||
443 | RelativePath=".\llpacketack.h"> | 458 | RelativePath=".\llpacketack.h"> |
444 | </File> | 459 | </File> |
445 | <File | 460 | <File |
@@ -530,6 +545,9 @@ | |||
530 | RelativePath=".\llxfermanager.h"> | 545 | RelativePath=".\llxfermanager.h"> |
531 | </File> | 546 | </File> |
532 | <File | 547 | <File |
548 | RelativePath=".\llxorcipher.h"> | ||
549 | </File> | ||
550 | <File | ||
533 | RelativePath=".\machine.h"> | 551 | RelativePath=".\machine.h"> |
534 | </File> | 552 | </File> |
535 | <File | 553 | <File |
diff --git a/linden/indra/llmessage/llmessage_vc8.vcproj b/linden/indra/llmessage/llmessage_vc8.vcproj new file mode 100644 index 0000000..ac32525 --- /dev/null +++ b/linden/indra/llmessage/llmessage_vc8.vcproj | |||
@@ -0,0 +1,843 @@ | |||
1 | <?xml version="1.0" encoding="Windows-1252"?> | ||
2 | <VisualStudioProject | ||
3 | ProjectType="Visual C++" | ||
4 | Version="8.00" | ||
5 | Name="llmessage" | ||
6 | ProjectGUID="{E5D94794-5671-4BD6-A16D-26EC18F3DB34}" | ||
7 | RootNamespace="llmessage" | ||
8 | Keyword="Win32Proj" | ||
9 | > | ||
10 | <Platforms> | ||
11 | <Platform | ||
12 | Name="Win32" | ||
13 | /> | ||
14 | </Platforms> | ||
15 | <ToolFiles> | ||
16 | </ToolFiles> | ||
17 | <Configurations> | ||
18 | <Configuration | ||
19 | Name="Debug|Win32" | ||
20 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
21 | IntermediateDirectory="Debug" | ||
22 | ConfigurationType="4" | ||
23 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
24 | CharacterSet="1" | ||
25 | > | ||
26 | <Tool | ||
27 | Name="VCPreBuildEventTool" | ||
28 | /> | ||
29 | <Tool | ||
30 | Name="VCCustomBuildTool" | ||
31 | /> | ||
32 | <Tool | ||
33 | Name="VCXMLDataGeneratorTool" | ||
34 | /> | ||
35 | <Tool | ||
36 | Name="VCWebServiceProxyGeneratorTool" | ||
37 | /> | ||
38 | <Tool | ||
39 | Name="VCMIDLTool" | ||
40 | /> | ||
41 | <Tool | ||
42 | Name="VCCLCompilerTool" | ||
43 | Optimization="0" | ||
44 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
45 | PreprocessorDefinitions="WIN32;_DEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_DEBUG" | ||
46 | MinimalRebuild="true" | ||
47 | BasicRuntimeChecks="3" | ||
48 | RuntimeLibrary="1" | ||
49 | StructMemberAlignment="4" | ||
50 | TreatWChar_tAsBuiltInType="false" | ||
51 | ForceConformanceInForLoopScope="true" | ||
52 | UsePrecompiledHeader="0" | ||
53 | WarningLevel="3" | ||
54 | WarnAsError="true" | ||
55 | Detect64BitPortabilityProblems="false" | ||
56 | DebugInformationFormat="4" | ||
57 | /> | ||
58 | <Tool | ||
59 | Name="VCManagedResourceCompilerTool" | ||
60 | /> | ||
61 | <Tool | ||
62 | Name="VCResourceCompilerTool" | ||
63 | /> | ||
64 | <Tool | ||
65 | Name="VCPreLinkEventTool" | ||
66 | /> | ||
67 | <Tool | ||
68 | Name="VCLibrarianTool" | ||
69 | OutputFile="$(OutDir)/llmessage.lib" | ||
70 | /> | ||
71 | <Tool | ||
72 | Name="VCALinkTool" | ||
73 | /> | ||
74 | <Tool | ||
75 | Name="VCXDCMakeTool" | ||
76 | /> | ||
77 | <Tool | ||
78 | Name="VCBscMakeTool" | ||
79 | /> | ||
80 | <Tool | ||
81 | Name="VCFxCopTool" | ||
82 | /> | ||
83 | <Tool | ||
84 | Name="VCPostBuildEventTool" | ||
85 | /> | ||
86 | </Configuration> | ||
87 | <Configuration | ||
88 | Name="Release|Win32" | ||
89 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
90 | IntermediateDirectory="Release" | ||
91 | ConfigurationType="4" | ||
92 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
93 | CharacterSet="1" | ||
94 | > | ||
95 | <Tool | ||
96 | Name="VCPreBuildEventTool" | ||
97 | /> | ||
98 | <Tool | ||
99 | Name="VCCustomBuildTool" | ||
100 | /> | ||
101 | <Tool | ||
102 | Name="VCXMLDataGeneratorTool" | ||
103 | /> | ||
104 | <Tool | ||
105 | Name="VCWebServiceProxyGeneratorTool" | ||
106 | /> | ||
107 | <Tool | ||
108 | Name="VCMIDLTool" | ||
109 | /> | ||
110 | <Tool | ||
111 | Name="VCCLCompilerTool" | ||
112 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
113 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" | ||
114 | RuntimeLibrary="0" | ||
115 | StructMemberAlignment="0" | ||
116 | TreatWChar_tAsBuiltInType="false" | ||
117 | ForceConformanceInForLoopScope="true" | ||
118 | UsePrecompiledHeader="0" | ||
119 | WarningLevel="3" | ||
120 | WarnAsError="true" | ||
121 | Detect64BitPortabilityProblems="false" | ||
122 | DebugInformationFormat="3" | ||
123 | /> | ||
124 | <Tool | ||
125 | Name="VCManagedResourceCompilerTool" | ||
126 | /> | ||
127 | <Tool | ||
128 | Name="VCResourceCompilerTool" | ||
129 | /> | ||
130 | <Tool | ||
131 | Name="VCPreLinkEventTool" | ||
132 | /> | ||
133 | <Tool | ||
134 | Name="VCLibrarianTool" | ||
135 | OutputFile="$(OutDir)/llmessage.lib" | ||
136 | /> | ||
137 | <Tool | ||
138 | Name="VCALinkTool" | ||
139 | /> | ||
140 | <Tool | ||
141 | Name="VCXDCMakeTool" | ||
142 | /> | ||
143 | <Tool | ||
144 | Name="VCBscMakeTool" | ||
145 | /> | ||
146 | <Tool | ||
147 | Name="VCFxCopTool" | ||
148 | /> | ||
149 | <Tool | ||
150 | Name="VCPostBuildEventTool" | ||
151 | /> | ||
152 | </Configuration> | ||
153 | <Configuration | ||
154 | Name="ReleaseNoOpt|Win32" | ||
155 | OutputDirectory="../lib_$(ConfigurationName)/i686-win32" | ||
156 | IntermediateDirectory="$(ConfigurationName)" | ||
157 | ConfigurationType="4" | ||
158 | InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" | ||
159 | CharacterSet="1" | ||
160 | > | ||
161 | <Tool | ||
162 | Name="VCPreBuildEventTool" | ||
163 | /> | ||
164 | <Tool | ||
165 | Name="VCCustomBuildTool" | ||
166 | /> | ||
167 | <Tool | ||
168 | Name="VCXMLDataGeneratorTool" | ||
169 | /> | ||
170 | <Tool | ||
171 | Name="VCWebServiceProxyGeneratorTool" | ||
172 | /> | ||
173 | <Tool | ||
174 | Name="VCMIDLTool" | ||
175 | /> | ||
176 | <Tool | ||
177 | Name="VCCLCompilerTool" | ||
178 | Optimization="0" | ||
179 | AdditionalIncludeDirectories="..\llcommon;..\llmath;..\llvfs;..\..\libraries\i686-win32\include;..\..\libraries\include\" | ||
180 | PreprocessorDefinitions="WIN32;NDEBUG;_LIB;LL_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_USE_32BIT_TIME_T;LL_RELEASE" | ||
181 | RuntimeLibrary="0" | ||
182 | StructMemberAlignment="0" | ||
183 | TreatWChar_tAsBuiltInType="false" | ||
184 | ForceConformanceInForLoopScope="true" | ||
185 | UsePrecompiledHeader="0" | ||
186 | WarningLevel="3" | ||
187 | WarnAsError="true" | ||
188 | Detect64BitPortabilityProblems="false" | ||
189 | DebugInformationFormat="3" | ||
190 | /> | ||
191 | <Tool | ||
192 | Name="VCManagedResourceCompilerTool" | ||
193 | /> | ||
194 | <Tool | ||
195 | Name="VCResourceCompilerTool" | ||
196 | /> | ||
197 | <Tool | ||
198 | Name="VCPreLinkEventTool" | ||
199 | /> | ||
200 | <Tool | ||
201 | Name="VCLibrarianTool" | ||
202 | OutputFile="$(OutDir)/llmessage.lib" | ||
203 | /> | ||
204 | <Tool | ||
205 | Name="VCALinkTool" | ||
206 | /> | ||
207 | <Tool | ||
208 | Name="VCXDCMakeTool" | ||
209 | /> | ||
210 | <Tool | ||
211 | Name="VCBscMakeTool" | ||
212 | /> | ||
213 | <Tool | ||
214 | Name="VCFxCopTool" | ||
215 | /> | ||
216 | <Tool | ||
217 | Name="VCPostBuildEventTool" | ||
218 | /> | ||
219 | </Configuration> | ||
220 | </Configurations> | ||
221 | <References> | ||
222 | </References> | ||
223 | <Files> | ||
224 | <Filter | ||
225 | Name="Source Files" | ||
226 | Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" | ||
227 | UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" | ||
228 | > | ||
229 | <File | ||
230 | RelativePath=".\llassetstorage.cpp" | ||
231 | > | ||
232 | </File> | ||
233 | <File | ||
234 | RelativePath=".\llblowfishcipher.cpp" | ||
235 | > | ||
236 | </File> | ||
237 | <File | ||
238 | RelativePath=".\llbuffer.cpp" | ||
239 | > | ||
240 | </File> | ||
241 | <File | ||
242 | RelativePath=".\llbufferstream.cpp" | ||
243 | > | ||
244 | </File> | ||
245 | <File | ||
246 | RelativePath=".\llcachename.cpp" | ||
247 | > | ||
248 | </File> | ||
249 | <File | ||
250 | RelativePath=".\llchainio.cpp" | ||
251 | > | ||
252 | </File> | ||
253 | <File | ||
254 | RelativePath=".\llcircuit.cpp" | ||
255 | > | ||
256 | </File> | ||
257 | <File | ||
258 | RelativePath=".\llclassifiedflags.cpp" | ||
259 | > | ||
260 | </File> | ||
261 | <File | ||
262 | RelativePath=".\llcurl.cpp" | ||
263 | > | ||
264 | </File> | ||
265 | <File | ||
266 | RelativePath=".\lldatapacker.cpp" | ||
267 | > | ||
268 | </File> | ||
269 | <File | ||
270 | RelativePath=".\lldispatcher.cpp" | ||
271 | > | ||
272 | </File> | ||
273 | <File | ||
274 | RelativePath=".\llfiltersd2xmlrpc.cpp" | ||
275 | > | ||
276 | </File> | ||
277 | <File | ||
278 | RelativePath=".\llhost.cpp" | ||
279 | > | ||
280 | </File> | ||
281 | <File | ||
282 | RelativePath=".\llhttpassetstorage.cpp" | ||
283 | > | ||
284 | </File> | ||
285 | <File | ||
286 | RelativePath=".\llhttpassetstorage.h" | ||
287 | > | ||
288 | </File> | ||
289 | <File | ||
290 | RelativePath=".\llhttpclient.cpp" | ||
291 | > | ||
292 | </File> | ||
293 | <File | ||
294 | RelativePath=".\llhttpnode.cpp" | ||
295 | > | ||
296 | </File> | ||
297 | <File | ||
298 | RelativePath=".\llinstantmessage.cpp" | ||
299 | > | ||
300 | </File> | ||
301 | <File | ||
302 | RelativePath=".\lliobuffer.cpp" | ||
303 | > | ||
304 | </File> | ||
305 | <File | ||
306 | RelativePath=".\lliohttpserver.cpp" | ||
307 | > | ||
308 | </File> | ||
309 | <File | ||
310 | RelativePath=".\lliopipe.cpp" | ||
311 | > | ||
312 | </File> | ||
313 | <File | ||
314 | RelativePath=".\lliosocket.cpp" | ||
315 | > | ||
316 | </File> | ||
317 | <File | ||
318 | RelativePath=".\llioutil.cpp" | ||
319 | > | ||
320 | </File> | ||
321 | <File | ||
322 | RelativePath=".\lllogtextmessage.cpp" | ||
323 | > | ||
324 | </File> | ||
325 | <File | ||
326 | RelativePath=".\llmail.cpp" | ||
327 | > | ||
328 | </File> | ||
329 | <File | ||
330 | RelativePath=".\llmessagethrottle.cpp" | ||
331 | > | ||
332 | </File> | ||
333 | <File | ||
334 | RelativePath=".\llmime.cpp" | ||
335 | > | ||
336 | </File> | ||
337 | <File | ||
338 | RelativePath=".\llnamevalue.cpp" | ||
339 | > | ||
340 | </File> | ||
341 | <File | ||
342 | RelativePath=".\llnullcipher.cpp" | ||
343 | > | ||
344 | </File> | ||
345 | <File | ||
346 | RelativePath=".\llpacketbuffer.cpp" | ||
347 | > | ||
348 | </File> | ||
349 | <File | ||
350 | RelativePath=".\llpacketring.cpp" | ||
351 | > | ||
352 | </File> | ||
353 | <File | ||
354 | RelativePath=".\llpartdata.cpp" | ||
355 | > | ||
356 | </File> | ||
357 | <File | ||
358 | RelativePath=".\llpumpio.cpp" | ||
359 | > | ||
360 | </File> | ||
361 | <File | ||
362 | RelativePath=".\llsdappservices.cpp" | ||
363 | > | ||
364 | </File> | ||
365 | <File | ||
366 | RelativePath=".\llsdhttpserver.cpp" | ||
367 | > | ||
368 | </File> | ||
369 | <File | ||
370 | RelativePath=".\llsdmessagesystem.cpp" | ||
371 | > | ||
372 | </File> | ||
373 | <File | ||
374 | RelativePath=".\llsdrpcclient.cpp" | ||
375 | > | ||
376 | </File> | ||
377 | <File | ||
378 | RelativePath=".\llsdrpcserver.cpp" | ||
379 | > | ||
380 | </File> | ||
381 | <File | ||
382 | RelativePath=".\llservice.cpp" | ||
383 | > | ||
384 | </File> | ||
385 | <File | ||
386 | RelativePath=".\llthrottle.cpp" | ||
387 | > | ||
388 | </File> | ||
389 | <File | ||
390 | RelativePath=".\lltransfermanager.cpp" | ||
391 | > | ||
392 | </File> | ||
393 | <File | ||
394 | RelativePath=".\lltransfersourceasset.cpp" | ||
395 | > | ||
396 | </File> | ||
397 | <File | ||
398 | RelativePath=".\lltransfersourcefile.cpp" | ||
399 | > | ||
400 | </File> | ||
401 | <File | ||
402 | RelativePath=".\lltransfertargetfile.cpp" | ||
403 | > | ||
404 | </File> | ||
405 | <File | ||
406 | RelativePath=".\lltransfertargetvfile.cpp" | ||
407 | > | ||
408 | </File> | ||
409 | <File | ||
410 | RelativePath=".\llurlrequest.cpp" | ||
411 | > | ||
412 | </File> | ||
413 | <File | ||
414 | RelativePath=".\lluseroperation.cpp" | ||
415 | > | ||
416 | </File> | ||
417 | <File | ||
418 | RelativePath=".\llxfer.cpp" | ||
419 | > | ||
420 | </File> | ||
421 | <File | ||
422 | RelativePath=".\llxfer_file.cpp" | ||
423 | > | ||
424 | </File> | ||
425 | <File | ||
426 | RelativePath=".\llxfer_mem.cpp" | ||
427 | > | ||
428 | </File> | ||
429 | <File | ||
430 | RelativePath=".\llxfer_vfile.cpp" | ||
431 | > | ||
432 | </File> | ||
433 | <File | ||
434 | RelativePath=".\llxfermanager.cpp" | ||
435 | > | ||
436 | </File> | ||
437 | <File | ||
438 | RelativePath=".\llxorcipher.cpp" | ||
439 | > | ||
440 | </File> | ||
441 | <File | ||
442 | RelativePath=".\message.cpp" | ||
443 | > | ||
444 | </File> | ||
445 | <File | ||
446 | RelativePath=".\message_prehash.cpp" | ||
447 | > | ||
448 | </File> | ||
449 | <File | ||
450 | RelativePath=".\message_string_table.cpp" | ||
451 | > | ||
452 | </File> | ||
453 | <File | ||
454 | RelativePath=".\net.cpp" | ||
455 | > | ||
456 | </File> | ||
457 | <File | ||
458 | RelativePath=".\network.cpp" | ||
459 | > | ||
460 | </File> | ||
461 | <File | ||
462 | RelativePath=".\partsyspacket.cpp" | ||
463 | > | ||
464 | </File> | ||
465 | <File | ||
466 | RelativePath=".\patch_code.cpp" | ||
467 | > | ||
468 | </File> | ||
469 | <File | ||
470 | RelativePath=".\patch_dct.cpp" | ||
471 | > | ||
472 | </File> | ||
473 | <File | ||
474 | RelativePath=".\patch_idct.cpp" | ||
475 | > | ||
476 | </File> | ||
477 | </Filter> | ||
478 | <Filter | ||
479 | Name="Header Files" | ||
480 | Filter="h;hpp;hxx;hm;inl;inc;xsd" | ||
481 | UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" | ||
482 | > | ||
483 | <File | ||
484 | RelativePath=".\camera.h" | ||
485 | > | ||
486 | </File> | ||
487 | <File | ||
488 | RelativePath=".\coordframe.h" | ||
489 | > | ||
490 | </File> | ||
491 | <File | ||
492 | RelativePath=".\llassetstorage.h" | ||
493 | > | ||
494 | </File> | ||
495 | <File | ||
496 | RelativePath=".\llblowfishcipher.h" | ||
497 | > | ||
498 | </File> | ||
499 | <File | ||
500 | RelativePath=".\llbuffer.h" | ||
501 | > | ||
502 | </File> | ||
503 | <File | ||
504 | RelativePath=".\llbufferstream.h" | ||
505 | > | ||
506 | </File> | ||
507 | <File | ||
508 | RelativePath=".\llcachename.h" | ||
509 | > | ||
510 | </File> | ||
511 | <File | ||
512 | RelativePath=".\llcallbacklisth.h" | ||
513 | > | ||
514 | </File> | ||
515 | <File | ||
516 | RelativePath=".\llcamera.h" | ||
517 | > | ||
518 | </File> | ||
519 | <File | ||
520 | RelativePath=".\llchainio.h" | ||
521 | > | ||
522 | </File> | ||
523 | <File | ||
524 | RelativePath=".\llcipher.h" | ||
525 | > | ||
526 | </File> | ||
527 | <File | ||
528 | RelativePath=".\llcircuit.h" | ||
529 | > | ||
530 | </File> | ||
531 | <File | ||
532 | RelativePath=".\llclassifiedflags.h" | ||
533 | > | ||
534 | </File> | ||
535 | <File | ||
536 | RelativePath=".\llcoordframe.h" | ||
537 | > | ||
538 | </File> | ||
539 | <File | ||
540 | RelativePath=".\llcurl.h" | ||
541 | > | ||
542 | </File> | ||
543 | <File | ||
544 | RelativePath=".\lldatapacker.h" | ||
545 | > | ||
546 | </File> | ||
547 | <File | ||
548 | RelativePath=".\lldbstrings.h" | ||
549 | > | ||
550 | </File> | ||
551 | <File | ||
552 | RelativePath=".\lldispatcher.h" | ||
553 | > | ||
554 | </File> | ||
555 | <File | ||
556 | RelativePath=".\lleventflags.h" | ||
557 | > | ||
558 | </File> | ||
559 | <File | ||
560 | RelativePath=".\llfiltersd2xmlrpc.h" | ||
561 | > | ||
562 | </File> | ||
563 | <File | ||
564 | RelativePath=".\llfollowcamparams.h" | ||
565 | > | ||
566 | </File> | ||
567 | <File | ||
568 | RelativePath=".\llhost.h" | ||
569 | > | ||
570 | </File> | ||
571 | <File | ||
572 | RelativePath=".\llhttpclient.h" | ||
573 | > | ||
574 | </File> | ||
575 | <File | ||
576 | RelativePath=".\llinstantmessage.h" | ||
577 | > | ||
578 | </File> | ||
579 | <File | ||
580 | RelativePath=".\llinvite.h" | ||
581 | > | ||
582 | </File> | ||
583 | <File | ||
584 | RelativePath=".\lliobuffer.h" | ||
585 | > | ||
586 | </File> | ||
587 | <File | ||
588 | RelativePath=".\lliohttpserver.h" | ||
589 | > | ||
590 | </File> | ||
591 | <File | ||
592 | RelativePath=".\lliopipe.h" | ||
593 | > | ||
594 | </File> | ||
595 | <File | ||
596 | RelativePath=".\lliosocket.h" | ||
597 | > | ||
598 | </File> | ||
599 | <File | ||
600 | RelativePath=".\llioutil.h" | ||
601 | > | ||
602 | </File> | ||
603 | <File | ||
604 | RelativePath=".\llloginflags.h" | ||
605 | > | ||
606 | </File> | ||
607 | <File | ||
608 | RelativePath=".\lllogtextmessage.h" | ||
609 | > | ||
610 | </File> | ||
611 | <File | ||
612 | RelativePath=".\lllsltransmit.h" | ||
613 | > | ||
614 | </File> | ||
615 | <File | ||
616 | RelativePath=".\llmail.h" | ||
617 | > | ||
618 | </File> | ||
619 | <File | ||
620 | RelativePath=".\llmessagethrottle.h" | ||
621 | > | ||
622 | </File> | ||
623 | <File | ||
624 | RelativePath=".\llmime.h" | ||
625 | > | ||
626 | </File> | ||
627 | <File | ||
628 | RelativePath=".\llnamevalue.h" | ||
629 | > | ||
630 | </File> | ||
631 | <File | ||
632 | RelativePath=".\llnullcipher.h" | ||
633 | > | ||
634 | </File> | ||
635 | <File | ||
636 | RelativePath=".\llpacketack.h" | ||
637 | > | ||
638 | </File> | ||
639 | <File | ||
640 | RelativePath=".\llpacketbuffer.h" | ||
641 | > | ||
642 | </File> | ||
643 | <File | ||
644 | RelativePath=".\llpacketring.h" | ||
645 | > | ||
646 | </File> | ||
647 | <File | ||
648 | RelativePath=".\llpartdata.h" | ||
649 | > | ||
650 | </File> | ||
651 | <File | ||
652 | RelativePath=".\llpumpio.h" | ||
653 | > | ||
654 | </File> | ||
655 | <File | ||
656 | RelativePath=".\llqueryflags.h" | ||
657 | > | ||
658 | </File> | ||
659 | <File | ||
660 | RelativePath=".\llregionflags.h" | ||
661 | > | ||
662 | </File> | ||
663 | <File | ||
664 | RelativePath=".\llregionhandle.h" | ||
665 | > | ||
666 | </File> | ||
667 | <File | ||
668 | RelativePath=".\llsdappservices.h" | ||
669 | > | ||
670 | </File> | ||
671 | <File | ||
672 | RelativePath=".\llsdhttpserver.h" | ||
673 | > | ||
674 | </File> | ||
675 | <File | ||
676 | RelativePath=".\llsdmessagesystem.h" | ||
677 | > | ||
678 | </File> | ||
679 | <File | ||
680 | RelativePath=".\llsdrpcclient.h" | ||
681 | > | ||
682 | </File> | ||
683 | <File | ||
684 | RelativePath=".\llsdrpcserver.h" | ||
685 | > | ||
686 | </File> | ||
687 | <File | ||
688 | RelativePath=".\llservice.h" | ||
689 | > | ||
690 | </File> | ||
691 | <File | ||
692 | RelativePath=".\lltaskname.h" | ||
693 | > | ||
694 | </File> | ||
695 | <File | ||
696 | RelativePath=".\llteleportflags.h" | ||
697 | > | ||
698 | </File> | ||
699 | <File | ||
700 | RelativePath=".\llthrottle.h" | ||
701 | > | ||
702 | </File> | ||
703 | <File | ||
704 | RelativePath=".\lltransfermanager.h" | ||
705 | > | ||
706 | </File> | ||
707 | <File | ||
708 | RelativePath=".\lltransfersourceasset.h" | ||
709 | > | ||
710 | </File> | ||
711 | <File | ||
712 | RelativePath=".\lltransfersourcefile.h" | ||
713 | > | ||
714 | </File> | ||
715 | <File | ||
716 | RelativePath=".\lltransfertargetfile.h" | ||
717 | > | ||
718 | </File> | ||
719 | <File | ||
720 | RelativePath=".\lltransfertargetvfile.h" | ||
721 | > | ||
722 | </File> | ||
723 | <File | ||
724 | RelativePath=".\llurlrequest.h" | ||
725 | > | ||
726 | </File> | ||
727 | <File | ||
728 | RelativePath=".\lluseroperation.h" | ||
729 | > | ||
730 | </File> | ||
731 | <File | ||
732 | RelativePath=".\llvehicleparams.h" | ||
733 | > | ||
734 | </File> | ||
735 | <File | ||
736 | RelativePath=".\llxfer.h" | ||
737 | > | ||
738 | </File> | ||
739 | <File | ||
740 | RelativePath=".\llxfer_file.h" | ||
741 | > | ||
742 | </File> | ||
743 | <File | ||
744 | RelativePath=".\llxfer_mem.h" | ||
745 | > | ||
746 | </File> | ||
747 | <File | ||
748 | RelativePath=".\llxfer_vfile.h" | ||
749 | > | ||
750 | </File> | ||
751 | <File | ||
752 | RelativePath=".\llxfermanager.h" | ||
753 | > | ||
754 | </File> | ||
755 | <File | ||
756 | RelativePath=".\llxorcipher.h" | ||
757 | > | ||
758 | </File> | ||
759 | <File | ||
760 | RelativePath=".\machine.h" | ||
761 | > | ||
762 | </File> | ||
763 | <File | ||
764 | RelativePath=".\mean_collision_data.h" | ||
765 | > | ||
766 | </File> | ||
767 | <File | ||
768 | RelativePath=".\message.h" | ||
769 | > | ||
770 | </File> | ||
771 | <File | ||
772 | RelativePath=".\message_prehash.h" | ||
773 | > | ||
774 | </File> | ||
775 | <File | ||
776 | RelativePath=".\net.h" | ||
777 | > | ||
778 | </File> | ||
779 | <File | ||
780 | RelativePath=".\network.h" | ||
781 | > | ||
782 | </File> | ||
783 | <File | ||
784 | RelativePath=".\partsyspacket.h" | ||
785 | > | ||
786 | </File> | ||
787 | <File | ||
788 | RelativePath=".\patch_code.h" | ||
789 | > | ||
790 | </File> | ||
791 | <File | ||
792 | RelativePath=".\patch_dct.h" | ||
793 | > | ||
794 | </File> | ||
795 | <File | ||
796 | RelativePath=".\sound_ids.h" | ||
797 | > | ||
798 | </File> | ||
799 | </Filter> | ||
800 | <Filter | ||
801 | Name="Resource Files" | ||
802 | Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx" | ||
803 | UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" | ||
804 | > | ||
805 | </Filter> | ||
806 | <File | ||
807 | RelativePath="..\..\scripts\messages\message_template.msg" | ||
808 | > | ||
809 | <FileConfiguration | ||
810 | Name="Debug|Win32" | ||
811 | > | ||
812 | <Tool | ||
813 | Name="VCCustomBuildTool" | ||
814 | Description="" | ||
815 | CommandLine="" | ||
816 | Outputs="" | ||
817 | /> | ||
818 | </FileConfiguration> | ||
819 | <FileConfiguration | ||
820 | Name="Release|Win32" | ||
821 | > | ||
822 | <Tool | ||
823 | Name="VCCustomBuildTool" | ||
824 | Description="" | ||
825 | CommandLine="" | ||
826 | Outputs="" | ||
827 | /> | ||
828 | </FileConfiguration> | ||
829 | <FileConfiguration | ||
830 | Name="ReleaseNoOpt|Win32" | ||
831 | > | ||
832 | <Tool | ||
833 | Name="VCCustomBuildTool" | ||
834 | Description="" | ||
835 | CommandLine="" | ||
836 | Outputs="" | ||
837 | /> | ||
838 | </FileConfiguration> | ||
839 | </File> | ||
840 | </Files> | ||
841 | <Globals> | ||
842 | </Globals> | ||
843 | </VisualStudioProject> | ||
diff --git a/linden/indra/llmessage/llnamevalue.cpp b/linden/indra/llmessage/llnamevalue.cpp index 0b4f0b6..1304923 100644 --- a/linden/indra/llmessage/llnamevalue.cpp +++ b/linden/indra/llmessage/llnamevalue.cpp | |||
@@ -59,7 +59,7 @@ user_callback_map_t gUserCallbackMap; | |||
59 | 59 | ||
60 | LLStringTable gNVNameTable(16384); | 60 | LLStringTable gNVNameTable(16384); |
61 | 61 | ||
62 | char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH] = | 62 | char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH] = /*Flawfinder: Ignore*/ |
63 | { | 63 | { |
64 | "NULL", | 64 | "NULL", |
65 | "STRING", | 65 | "STRING", |
@@ -70,17 +70,17 @@ char NameValueTypeStrings[NVT_EOF][NAME_VALUE_TYPE_STRING_LENGTH] = | |||
70 | "CAMERA", // Deprecated, but leaving in case removing completely would cause problems | 70 | "CAMERA", // Deprecated, but leaving in case removing completely would cause problems |
71 | "ASSET", | 71 | "ASSET", |
72 | "U64" | 72 | "U64" |
73 | }; /*Flawfinder: Ignore*/ | 73 | }; |
74 | 74 | ||
75 | char NameValueClassStrings[NVC_EOF][NAME_VALUE_CLASS_STRING_LENGTH] = | 75 | char NameValueClassStrings[NVC_EOF][NAME_VALUE_CLASS_STRING_LENGTH] = /*Flawfinder: Ignore*/ |
76 | { | 76 | { |
77 | "NULL", | 77 | "NULL", |
78 | "R", // read only | 78 | "R", // read only |
79 | "RW", // read write | 79 | "RW", // read write |
80 | "CB" // callback | 80 | "CB" // callback |
81 | }; /*Flawfinder: Ignore*/ | 81 | }; |
82 | 82 | ||
83 | char NameValueSendtoStrings[NVS_EOF][NAME_VALUE_SENDTO_STRING_LENGTH] = | 83 | char NameValueSendtoStrings[NVS_EOF][NAME_VALUE_SENDTO_STRING_LENGTH] = /*Flawfinder: Ignore*/ |
84 | { | 84 | { |
85 | "NULL", | 85 | "NULL", |
86 | "S", // "Sim", formerly SIM | 86 | "S", // "Sim", formerly SIM |
@@ -412,11 +412,11 @@ LLNameValue::LLNameValue(const char *name, const char *type, const char *nvclass | |||
412 | LLNameValue::LLNameValue(const char *data) | 412 | LLNameValue::LLNameValue(const char *data) |
413 | { | 413 | { |
414 | baseInit(); | 414 | baseInit(); |
415 | static char name[NV_BUFFER_LEN]; | 415 | static char name[NV_BUFFER_LEN]; /*Flawfinder: ignore*/ |
416 | static char type[NV_BUFFER_LEN]; | 416 | static char type[NV_BUFFER_LEN]; /*Flawfinder: ignore*/ |
417 | static char nvclass[NV_BUFFER_LEN]; | 417 | static char nvclass[NV_BUFFER_LEN]; /*Flawfinder: ignore*/ |
418 | static char nvsendto[NV_BUFFER_LEN]; | 418 | static char nvsendto[NV_BUFFER_LEN]; /*Flawfinder: ignore*/ |
419 | static char nvdata[NV_BUFFER_LEN]; | 419 | static char nvdata[NV_BUFFER_LEN]; /*Flawfinder: ignore*/ |
420 | 420 | ||
421 | S32 i; | 421 | S32 i; |
422 | 422 | ||
@@ -440,7 +440,7 @@ LLNameValue::LLNameValue(const char *data) | |||
440 | } | 440 | } |
441 | 441 | ||
442 | // read in the name | 442 | // read in the name |
443 | sscanf((data + character_count), "%2047s", name); | 443 | sscanf((data + character_count), "%2047s", name); /*Flawfinder: ignore*/ |
444 | 444 | ||
445 | // bump past it and add null terminator | 445 | // bump past it and add null terminator |
446 | length = (S32)strlen(name); /* Flawfinder: ignore */ | 446 | length = (S32)strlen(name); /* Flawfinder: ignore */ |
@@ -464,7 +464,7 @@ LLNameValue::LLNameValue(const char *data) | |||
464 | } | 464 | } |
465 | 465 | ||
466 | // read in the type | 466 | // read in the type |
467 | sscanf((data + character_count), "%2047s", type); | 467 | sscanf((data + character_count), "%2047s", type); /*Flawfinder: ignore*/ |
468 | 468 | ||
469 | // bump past it and add null terminator | 469 | // bump past it and add null terminator |
470 | length = (S32)strlen(type); /* Flawfinder: ignore */ | 470 | length = (S32)strlen(type); /* Flawfinder: ignore */ |
@@ -500,7 +500,7 @@ LLNameValue::LLNameValue(const char *data) | |||
500 | { | 500 | { |
501 | // yes we do! | 501 | // yes we do! |
502 | // read in the class | 502 | // read in the class |
503 | sscanf((data + character_count), "%2047s", nvclass); | 503 | sscanf((data + character_count), "%2047s", nvclass); /*Flawfinder: ignore*/ |
504 | 504 | ||
505 | // bump past it and add null terminator | 505 | // bump past it and add null terminator |
506 | length = (S32)strlen(nvclass); /* Flawfinder: ignore */ | 506 | length = (S32)strlen(nvclass); /* Flawfinder: ignore */ |
@@ -542,7 +542,7 @@ LLNameValue::LLNameValue(const char *data) | |||
542 | if (i != NVS_EOF) | 542 | if (i != NVS_EOF) |
543 | { | 543 | { |
544 | // found a sendto argument | 544 | // found a sendto argument |
545 | sscanf((data + character_count), "%2047s", nvsendto); | 545 | sscanf((data + character_count), "%2047s", nvsendto); /*Flawfinder: ignore*/ |
546 | 546 | ||
547 | // add null terminator | 547 | // add null terminator |
548 | length = (S32)strlen(nvsendto); /* Flawfinder: ignore */ | 548 | length = (S32)strlen(nvsendto); /* Flawfinder: ignore */ |
diff --git a/linden/indra/llmessage/llnullcipher.cpp b/linden/indra/llmessage/llnullcipher.cpp index 1b60e44..ad2b25f 100644 --- a/linden/indra/llmessage/llnullcipher.cpp +++ b/linden/indra/llmessage/llnullcipher.cpp | |||
@@ -27,33 +27,33 @@ | |||
27 | 27 | ||
28 | #include "linden_common.h" | 28 | #include "linden_common.h" |
29 | 29 | ||
30 | #include "llcrypto.h" | 30 | #include "llnullcipher.h" |
31 | 31 | ||
32 | ///---------------------------------------------------------------------------- | 32 | ///---------------------------------------------------------------------------- |
33 | /// Class LLNullCipher | 33 | /// Class LLNullCipher |
34 | ///---------------------------------------------------------------------------- | 34 | ///---------------------------------------------------------------------------- |
35 | 35 | ||
36 | BOOL LLNullCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | 36 | U32 LLNullCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) |
37 | { | 37 | { |
38 | if((src_len == dst_len) && src && dst) | 38 | if((src_len == dst_len) && src && dst) |
39 | { | 39 | { |
40 | memmove(dst, src, src_len); | 40 | memmove(dst, src, src_len); |
41 | return TRUE; | 41 | return src_len; |
42 | } | 42 | } |
43 | return FALSE; | 43 | return 0; |
44 | } | 44 | } |
45 | 45 | ||
46 | BOOL LLNullCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | 46 | U32 LLNullCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) |
47 | { | 47 | { |
48 | if((src_len == dst_len) && src && dst) | 48 | if((src_len == dst_len) && src && dst) |
49 | { | 49 | { |
50 | memmove(dst, src, src_len); | 50 | memmove(dst, src, src_len); |
51 | return TRUE; | 51 | return src_len; |
52 | } | 52 | } |
53 | return FALSE; | 53 | return 0; |
54 | } | 54 | } |
55 | 55 | ||
56 | U32 LLNullCipher::requiredEncryptionSpace(U32 len) | 56 | U32 LLNullCipher::requiredEncryptionSpace(U32 len) const |
57 | { | 57 | { |
58 | return len; | 58 | return len; |
59 | } | 59 | } |
diff --git a/linden/indra/llmessage/llnullcipher.h b/linden/indra/llmessage/llnullcipher.h new file mode 100644 index 0000000..75d022d --- /dev/null +++ b/linden/indra/llmessage/llnullcipher.h | |||
@@ -0,0 +1,49 @@ | |||
1 | /** | ||
2 | * @file llnullcipher.h | ||
3 | * | ||
4 | * Copyright (c) 2003-2007, Linden Research, Inc. | ||
5 | * | ||
6 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
7 | * to you under the terms of the GNU General Public License, version 2.0 | ||
8 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
9 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
10 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
11 | * online at http://secondlife.com/developers/opensource/gplv2 | ||
12 | * | ||
13 | * There are special exceptions to the terms and conditions of the GPL as | ||
14 | * it is applied to this Source Code. View the full text of the exception | ||
15 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
16 | * online at http://secondlife.com/developers/opensource/flossexception | ||
17 | * | ||
18 | * By copying, modifying or distributing this software, you acknowledge | ||
19 | * that you have read and understood your obligations described above, | ||
20 | * and agree to abide by those obligations. | ||
21 | * | ||
22 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
23 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
24 | * COMPLETENESS OR PERFORMANCE. | ||
25 | */ | ||
26 | |||
27 | #ifndef LLNULLCIPHER_H | ||
28 | #define LLNULLCIPHER_H | ||
29 | |||
30 | #include "llcipher.h" | ||
31 | |||
32 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
33 | // Class LLNullCipher | ||
34 | // | ||
35 | // A class which implements LLCipher, but does not transform src | ||
36 | // during encryption. | ||
37 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
38 | |||
39 | class LLNullCipher : public LLCipher | ||
40 | { | ||
41 | public: | ||
42 | LLNullCipher() {} | ||
43 | virtual ~LLNullCipher() {} | ||
44 | virtual U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
45 | virtual U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
46 | virtual U32 requiredEncryptionSpace(U32 src_len) const; | ||
47 | }; | ||
48 | |||
49 | #endif | ||
diff --git a/linden/indra/llmessage/llpacketack.h b/linden/indra/llmessage/llpacketack.h index d7d960e..e8d598a 100644 --- a/linden/indra/llmessage/llpacketack.h +++ b/linden/indra/llmessage/llpacketack.h | |||
@@ -130,7 +130,7 @@ public: | |||
130 | mBuffer = new U8[buf_len]; | 130 | mBuffer = new U8[buf_len]; |
131 | if (mBuffer != NULL) | 131 | if (mBuffer != NULL) |
132 | { | 132 | { |
133 | memcpy(mBuffer,buf_ptr,buf_len); | 133 | memcpy(mBuffer,buf_ptr,buf_len); /*Flawfinder: ignore*/ |
134 | mBufferLength = buf_len; | 134 | mBufferLength = buf_len; |
135 | } | 135 | } |
136 | 136 | ||
diff --git a/linden/indra/llmessage/llpacketbuffer.cpp b/linden/indra/llmessage/llpacketbuffer.cpp index 3559ecb..855fb40 100644 --- a/linden/indra/llmessage/llpacketbuffer.cpp +++ b/linden/indra/llmessage/llpacketbuffer.cpp | |||
@@ -44,7 +44,7 @@ LLPacketBuffer::LLPacketBuffer(const LLHost &host, const char *datap, const S32 | |||
44 | 44 | ||
45 | if (datap != NULL) | 45 | if (datap != NULL) |
46 | { | 46 | { |
47 | memcpy(mData, datap, size); | 47 | memcpy(mData, datap, size); /*Flawfinder: ignore*/ |
48 | mSize = size; | 48 | mSize = size; |
49 | } | 49 | } |
50 | 50 | ||
diff --git a/linden/indra/llmessage/llpacketring.cpp b/linden/indra/llmessage/llpacketring.cpp index 6a6a456..a2e6eb9 100644 --- a/linden/indra/llmessage/llpacketring.cpp +++ b/linden/indra/llmessage/llpacketring.cpp | |||
@@ -132,7 +132,7 @@ S32 LLPacketRing::receiveFromRing (S32 socket, char *datap) | |||
132 | packet_size = packetp->getSize(); | 132 | packet_size = packetp->getSize(); |
133 | if (packetp->getData() != NULL) | 133 | if (packetp->getData() != NULL) |
134 | { | 134 | { |
135 | memcpy(datap, packetp->getData(), packet_size); | 135 | memcpy(datap, packetp->getData(), packet_size); /*Flawfinder: ignore*/ |
136 | } | 136 | } |
137 | // need to set sender IP/port!! | 137 | // need to set sender IP/port!! |
138 | mLastSender = packetp->getHost(); | 138 | mLastSender = packetp->getHost(); |
diff --git a/linden/indra/llmessage/llpartdata.cpp b/linden/indra/llmessage/llpartdata.cpp index 11969d0..de0cb13 100644 --- a/linden/indra/llmessage/llpartdata.cpp +++ b/linden/indra/llmessage/llpartdata.cpp | |||
@@ -231,6 +231,20 @@ BOOL LLPartSysData::unpack(LLDataPacker &dp) | |||
231 | return TRUE; | 231 | return TRUE; |
232 | } | 232 | } |
233 | 233 | ||
234 | std::ostream& operator<<(std::ostream& s, const LLPartSysData &data) | ||
235 | { | ||
236 | s << "Flags: " << std::hex << data.mFlags; | ||
237 | s << " Pattern: " << std::hex << (U32) data.mPattern << "\n"; | ||
238 | s << "Age: [" << data.mStartAge << ", " << data.mMaxAge << "]\n"; | ||
239 | s << "Angle: [" << data.mInnerAngle << ", " << data.mOuterAngle << "]\n"; | ||
240 | s << "Burst Rate: " << data.mBurstRate << "\n"; | ||
241 | s << "Burst Radius: " << data.mBurstRadius << "\n"; | ||
242 | s << "Burst Speed: [" << data.mBurstSpeedMin << ", " << data.mBurstSpeedMax << "]\n"; | ||
243 | s << "Burst Part Count: " << std::hex << (U32) data.mBurstPartCount << "\n"; | ||
244 | s << "Angular Velocity: " << data.mAngularVelocity << "\n"; | ||
245 | s << "Accel: " << data.mPartAccel; | ||
246 | return s; | ||
247 | } | ||
234 | 248 | ||
235 | BOOL LLPartSysData::isNullPS(const S32 block_num) | 249 | BOOL LLPartSysData::isNullPS(const S32 block_num) |
236 | { | 250 | { |
diff --git a/linden/indra/llmessage/llpartdata.h b/linden/indra/llmessage/llpartdata.h index 4045ada..55d22d5 100644 --- a/linden/indra/llmessage/llpartdata.h +++ b/linden/indra/llmessage/llpartdata.h | |||
@@ -186,6 +186,9 @@ public: | |||
186 | // a combination of multiple parameters, we | 186 | // a combination of multiple parameters, we |
187 | // need to clamp it using a separate method instead of an accessor. | 187 | // need to clamp it using a separate method instead of an accessor. |
188 | void clampSourceParticleRate(); | 188 | void clampSourceParticleRate(); |
189 | |||
190 | friend std::ostream& operator<<(std::ostream& s, const LLPartSysData &data); // Stream a | ||
191 | |||
189 | public: | 192 | public: |
190 | // Public because I'm lazy.... | 193 | // Public because I'm lazy.... |
191 | 194 | ||
diff --git a/linden/indra/llmessage/llpumpio.cpp b/linden/indra/llmessage/llpumpio.cpp index b1495f6..c1f1821 100644 --- a/linden/indra/llmessage/llpumpio.cpp +++ b/linden/indra/llmessage/llpumpio.cpp | |||
@@ -887,7 +887,7 @@ void LLPumpIO::processChain(LLChainInfo& chain) | |||
887 | PUMP_DEBUG; | 887 | PUMP_DEBUG; |
888 | if(LLIOPipe::isError(status)) | 888 | if(LLIOPipe::isError(status)) |
889 | { | 889 | { |
890 | llinfos << "Pump generated pipe error: '" | 890 | llinfos << "Pump generated pipe err: '" |
891 | #if LL_DEBUG_PIPE_TYPE_IN_PUMP | 891 | #if LL_DEBUG_PIPE_TYPE_IN_PUMP |
892 | << typeid(*((*it).mPipe)).name() << "':'" | 892 | << typeid(*((*it).mPipe)).name() << "':'" |
893 | #endif | 893 | #endif |
diff --git a/linden/indra/llmessage/llsdappservices.cpp b/linden/indra/llmessage/llsdappservices.cpp index d923b22..8574f87 100644 --- a/linden/indra/llmessage/llsdappservices.cpp +++ b/linden/indra/llmessage/llsdappservices.cpp | |||
@@ -261,7 +261,7 @@ public: | |||
261 | llinfos << "LLHTTPLiveConfigSingleService::validate(" << name | 261 | llinfos << "LLHTTPLiveConfigSingleService::validate(" << name |
262 | << ")" << llendl; | 262 | << ")" << llendl; |
263 | LLSD option = LLApp::instance()->getOption(name); | 263 | LLSD option = LLApp::instance()->getOption(name); |
264 | if(option) return true; | 264 | if(option.isDefined()) return true; |
265 | else return false; | 265 | else return false; |
266 | } | 266 | } |
267 | 267 | ||
diff --git a/linden/indra/llmessage/llsdmessagesystem.cpp b/linden/indra/llmessage/llsdmessagesystem.cpp index 7d508f0..66382ea 100644 --- a/linden/indra/llmessage/llsdmessagesystem.cpp +++ b/linden/indra/llmessage/llsdmessagesystem.cpp | |||
@@ -25,6 +25,7 @@ | |||
25 | * COMPLETENESS OR PERFORMANCE. | 25 | * COMPLETENESS OR PERFORMANCE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "linden_common.h" | ||
28 | #include "llsdmessagesystem.h" | 29 | #include "llsdmessagesystem.h" |
29 | 30 | ||
30 | #include "llhttpnode.h" | 31 | #include "llhttpnode.h" |
@@ -98,7 +99,7 @@ void LLSDMessageSystem::getStringFast(const char *block, const char *var, S32 bu | |||
98 | std::string data = getLLSD(mInput, block, var, blocknum).asString(); | 99 | std::string data = getLLSD(mInput, block, var, blocknum).asString(); |
99 | S32 length = data.length(); | 100 | S32 length = data.length(); |
100 | memset(buffer, 0, buffer_size); | 101 | memset(buffer, 0, buffer_size); |
101 | strncpy(buffer, data.c_str(), llmin(length, buffer_size)); | 102 | strncpy(buffer, data.c_str(), llmin(length, buffer_size)); /* Flawfinder: ignore */ |
102 | } | 103 | } |
103 | 104 | ||
104 | //virtual | 105 | //virtual |
diff --git a/linden/indra/llmessage/lltransfermanager.cpp b/linden/indra/llmessage/lltransfermanager.cpp index bfeedd0..43afa78 100644 --- a/linden/indra/llmessage/lltransfermanager.cpp +++ b/linden/indra/llmessage/lltransfermanager.cpp | |||
@@ -354,7 +354,7 @@ void LLTransferManager::processTransferInfo(LLMessageSystem *msgp, void **) | |||
354 | { | 354 | { |
355 | // Perhaps this stuff should be inside a method in LLTransferPacket? | 355 | // Perhaps this stuff should be inside a method in LLTransferPacket? |
356 | // I'm too lazy to do it now, though. | 356 | // I'm too lazy to do it now, though. |
357 | llinfos << "Playing back delayed packet " << packet_id << llendl; | 357 | // llinfos << "Playing back delayed packet " << packet_id << llendl; |
358 | LLTransferPacket *packetp = ttp->mDelayedPacketMap[packet_id]; | 358 | LLTransferPacket *packetp = ttp->mDelayedPacketMap[packet_id]; |
359 | 359 | ||
360 | // This is somewhat inefficient, but avoids us having to duplicate | 360 | // This is somewhat inefficient, but avoids us having to duplicate |
@@ -365,7 +365,7 @@ void LLTransferManager::processTransferInfo(LLMessageSystem *msgp, void **) | |||
365 | { | 365 | { |
366 | if ((packetp->mDatap != NULL) && (size<(S32)sizeof(tmp_data))) | 366 | if ((packetp->mDatap != NULL) && (size<(S32)sizeof(tmp_data))) |
367 | { | 367 | { |
368 | memcpy(tmp_data, packetp->mDatap, size); | 368 | memcpy(tmp_data, packetp->mDatap, size); /*Flawfinder: ignore*/ |
369 | } | 369 | } |
370 | } | 370 | } |
371 | status = packetp->mStatus; | 371 | status = packetp->mStatus; |
@@ -474,6 +474,8 @@ void LLTransferManager::processTransferPacket(LLMessageSystem *msgp, void **) | |||
474 | ttcp->deleteTransfer(ttp); | 474 | ttcp->deleteTransfer(ttp); |
475 | return; | 475 | return; |
476 | } | 476 | } |
477 | #if 0 | ||
478 | // Spammy! | ||
477 | const S32 LL_TRANSFER_WARN_GAP = 10; | 479 | const S32 LL_TRANSFER_WARN_GAP = 10; |
478 | if(!ttp->gotInfo()) | 480 | if(!ttp->gotInfo()) |
479 | { | 481 | { |
@@ -487,6 +489,7 @@ void LLTransferManager::processTransferPacket(LLMessageSystem *msgp, void **) | |||
487 | << " from " << msgp->getSender() << ", got " << packet_id | 489 | << " from " << msgp->getSender() << ", got " << packet_id |
488 | << " expecting " << ttp->getNextPacketID() << llendl; | 490 | << " expecting " << ttp->getNextPacketID() << llendl; |
489 | } | 491 | } |
492 | #endif | ||
490 | return; | 493 | return; |
491 | } | 494 | } |
492 | 495 | ||
@@ -527,7 +530,7 @@ void LLTransferManager::processTransferPacket(LLMessageSystem *msgp, void **) | |||
527 | { | 530 | { |
528 | // Perhaps this stuff should be inside a method in LLTransferPacket? | 531 | // Perhaps this stuff should be inside a method in LLTransferPacket? |
529 | // I'm too lazy to do it now, though. | 532 | // I'm too lazy to do it now, though. |
530 | llinfos << "Playing back delayed packet " << packet_id << llendl; | 533 | // llinfos << "Playing back delayed packet " << packet_id << llendl; |
531 | LLTransferPacket *packetp = ttp->mDelayedPacketMap[packet_id]; | 534 | LLTransferPacket *packetp = ttp->mDelayedPacketMap[packet_id]; |
532 | 535 | ||
533 | // This is somewhat inefficient, but avoids us having to duplicate | 536 | // This is somewhat inefficient, but avoids us having to duplicate |
@@ -538,7 +541,7 @@ void LLTransferManager::processTransferPacket(LLMessageSystem *msgp, void **) | |||
538 | { | 541 | { |
539 | if ((packetp->mDatap != NULL) && (size<(S32)sizeof(tmp_data))) | 542 | if ((packetp->mDatap != NULL) && (size<(S32)sizeof(tmp_data))) |
540 | { | 543 | { |
541 | memcpy(tmp_data, packetp->mDatap, size); | 544 | memcpy(tmp_data, packetp->mDatap, size); /*Flawfinder: ignore*/ |
542 | } | 545 | } |
543 | } | 546 | } |
544 | status = packetp->mStatus; | 547 | status = packetp->mStatus; |
@@ -738,8 +741,11 @@ LLTransferSourceChannel::LLTransferSourceChannel(const LLTransferChannelType cha | |||
738 | 741 | ||
739 | LLTransferSourceChannel::~LLTransferSourceChannel() | 742 | LLTransferSourceChannel::~LLTransferSourceChannel() |
740 | { | 743 | { |
741 | LLPriQueueMap<LLTransferSource *>::pqm_iter iter; | 744 | LLPriQueueMap<LLTransferSource*>::pqm_iter iter = |
742 | for (iter = mTransferSources.mMap.begin(); iter != mTransferSources.mMap.end(); iter++) | 745 | mTransferSources.mMap.begin(); |
746 | LLPriQueueMap<LLTransferSource*>::pqm_iter end = | ||
747 | mTransferSources.mMap.end(); | ||
748 | for (; iter != end; ++iter) | ||
743 | { | 749 | { |
744 | // Just kill off all of the transfers | 750 | // Just kill off all of the transfers |
745 | (*iter).second->abortTransfer(); | 751 | (*iter).second->abortTransfer(); |
@@ -1176,7 +1182,7 @@ LLTransferPacket::LLTransferPacket(const S32 packet_id, const LLTSCode status, c | |||
1176 | mDatap = new U8[size]; | 1182 | mDatap = new U8[size]; |
1177 | if (mDatap != NULL) | 1183 | if (mDatap != NULL) |
1178 | { | 1184 | { |
1179 | memcpy(mDatap, datap, size); | 1185 | memcpy(mDatap, datap, size); /*Flawfinder: ignore*/ |
1180 | } | 1186 | } |
1181 | } | 1187 | } |
1182 | 1188 | ||
diff --git a/linden/indra/llmessage/lltransfertargetvfile.cpp b/linden/indra/llmessage/lltransfertargetvfile.cpp index ce21605..5a1acf3 100644 --- a/linden/indra/llmessage/lltransfertargetvfile.cpp +++ b/linden/indra/llmessage/lltransfertargetvfile.cpp | |||
@@ -34,33 +34,8 @@ | |||
34 | #include "llvfile.h" | 34 | #include "llvfile.h" |
35 | 35 | ||
36 | //static | 36 | //static |
37 | std::list<LLTransferTargetParamsVFile*> LLTransferTargetVFile::sCallbackQueue; | ||
38 | |||
39 | //static | ||
40 | void LLTransferTargetVFile::updateQueue(bool shutdown) | 37 | void LLTransferTargetVFile::updateQueue(bool shutdown) |
41 | { | 38 | { |
42 | for(std::list<LLTransferTargetParamsVFile*>::iterator iter = sCallbackQueue.begin(); | ||
43 | iter != sCallbackQueue.end(); ) | ||
44 | { | ||
45 | std::list<LLTransferTargetParamsVFile*>::iterator curiter = iter++; | ||
46 | LLTransferTargetParamsVFile* params = *curiter; | ||
47 | LLVFSThread::status_t s = LLVFile::getVFSThread()->getRequestStatus(params->mHandle); | ||
48 | if (s == LLVFSThread::STATUS_COMPLETE || s == LLVFSThread::STATUS_EXPIRED) | ||
49 | { | ||
50 | params->mCompleteCallback( | ||
51 | params->mErrCode, | ||
52 | params->getAssetID(), | ||
53 | params->getAssetType(), | ||
54 | params->mUserDatap); | ||
55 | delete params; | ||
56 | iter = sCallbackQueue.erase(curiter); | ||
57 | } | ||
58 | else if (shutdown) | ||
59 | { | ||
60 | delete params; | ||
61 | iter = sCallbackQueue.erase(curiter); | ||
62 | } | ||
63 | } | ||
64 | } | 39 | } |
65 | 40 | ||
66 | 41 | ||
@@ -69,8 +44,7 @@ LLTransferTargetParamsVFile::LLTransferTargetParamsVFile() : | |||
69 | mAssetType(LLAssetType::AT_NONE), | 44 | mAssetType(LLAssetType::AT_NONE), |
70 | mCompleteCallback(NULL), | 45 | mCompleteCallback(NULL), |
71 | mUserDatap(NULL), | 46 | mUserDatap(NULL), |
72 | mErrCode(0), | 47 | mErrCode(0) |
73 | mHandle(LLVFSThread::nullHandle()) | ||
74 | { | 48 | { |
75 | } | 49 | } |
76 | 50 | ||
@@ -185,7 +159,6 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status) | |||
185 | llwarns << "Aborting vfile transfer after asset storage shut down!" << llendl; | 159 | llwarns << "Aborting vfile transfer after asset storage shut down!" << llendl; |
186 | return; | 160 | return; |
187 | } | 161 | } |
188 | LLVFSThread::handle_t handle = LLVFSThread::nullHandle(); | ||
189 | 162 | ||
190 | // Still need to gracefully handle error conditions. | 163 | // Still need to gracefully handle error conditions. |
191 | S32 err_code = 0; | 164 | S32 err_code = 0; |
@@ -194,11 +167,11 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status) | |||
194 | case LLTS_DONE: | 167 | case LLTS_DONE: |
195 | if (!mNeedsCreate) | 168 | if (!mNeedsCreate) |
196 | { | 169 | { |
197 | handle = LLVFile::getVFSThread()->rename( | 170 | LLVFile file(gAssetStorage->mVFS, mTempID, mParams.getAssetType(), LLVFile::WRITE); |
198 | gAssetStorage->mVFS, | 171 | if (!file.rename(mParams.getAssetID(), mParams.getAssetType())) |
199 | mTempID, mParams.getAssetType(), | 172 | { |
200 | mParams.getAssetID(), mParams.getAssetType(), | 173 | llerrs << "LLTransferTargetVFile: rename failed" << llendl; |
201 | LLVFSThread::AUTO_DELETE); | 174 | } |
202 | } | 175 | } |
203 | err_code = LL_ERR_NOERR; | 176 | err_code = LL_ERR_NOERR; |
204 | lldebugs << "LLTransferTargetVFile::completionCallback for " | 177 | lldebugs << "LLTransferTargetVFile::completionCallback for " |
@@ -238,20 +211,9 @@ void LLTransferTargetVFile::completionCallback(const LLTSCode status) | |||
238 | } | 211 | } |
239 | if (mParams.mCompleteCallback) | 212 | if (mParams.mCompleteCallback) |
240 | { | 213 | { |
241 | if (handle != LLVFSThread::nullHandle()) | 214 | mParams.mCompleteCallback(err_code, |
242 | { | 215 | mParams.getAssetID(), |
243 | LLTransferTargetParamsVFile* params = new LLTransferTargetParamsVFile(mParams); | 216 | mParams.getAssetType(), |
244 | params->mErrCode = err_code; | 217 | mParams.mUserDatap); |
245 | params->mHandle = handle; | ||
246 | sCallbackQueue.push_back(params); | ||
247 | } | ||
248 | else | ||
249 | { | ||
250 | mParams.mCompleteCallback( | ||
251 | err_code, | ||
252 | mParams.getAssetID(), | ||
253 | mParams.getAssetType(), | ||
254 | mParams.mUserDatap); | ||
255 | } | ||
256 | } | 218 | } |
257 | } | 219 | } |
diff --git a/linden/indra/llmessage/lltransfertargetvfile.h b/linden/indra/llmessage/lltransfertargetvfile.h index a4b6f93..4c915dc 100644 --- a/linden/indra/llmessage/lltransfertargetvfile.h +++ b/linden/indra/llmessage/lltransfertargetvfile.h | |||
@@ -90,8 +90,6 @@ protected: | |||
90 | 90 | ||
91 | BOOL mNeedsCreate; | 91 | BOOL mNeedsCreate; |
92 | LLUUID mTempID; | 92 | LLUUID mTempID; |
93 | |||
94 | static std::list<LLTransferTargetParamsVFile*> sCallbackQueue; | ||
95 | }; | 93 | }; |
96 | 94 | ||
97 | #endif // LL_LLTRANSFERTARGETFILE_H | 95 | #endif // LL_LLTRANSFERTARGETFILE_H |
diff --git a/linden/indra/llmessage/llxfer.cpp b/linden/indra/llmessage/llxfer.cpp index f02d106..507b820 100644 --- a/linden/indra/llmessage/llxfer.cpp +++ b/linden/indra/llmessage/llxfer.cpp | |||
@@ -135,7 +135,7 @@ S32 LLXfer::receiveData (char *datap, S32 data_size) | |||
135 | { | 135 | { |
136 | if (datap != NULL) | 136 | if (datap != NULL) |
137 | { | 137 | { |
138 | memcpy(&mBuffer[mBufferLength],datap,data_size); | 138 | memcpy(&mBuffer[mBufferLength],datap,data_size); /*Flawfinder: ignore*/ |
139 | mBufferLength += data_size; | 139 | mBufferLength += data_size; |
140 | } | 140 | } |
141 | else | 141 | else |
@@ -212,7 +212,7 @@ void LLXfer::sendPacket(S32 packet_num) | |||
212 | num_copy = llmin(num_copy, (S32)(mBufferLength - desired_read_position)); | 212 | num_copy = llmin(num_copy, (S32)(mBufferLength - desired_read_position)); |
213 | if (num_copy > 0) | 213 | if (num_copy > 0) |
214 | { | 214 | { |
215 | memcpy(fdata_buf,&mBuffer[desired_read_position],num_copy); | 215 | memcpy(fdata_buf,&mBuffer[desired_read_position],num_copy); /*Flawfinder: ignore*/ |
216 | } | 216 | } |
217 | } | 217 | } |
218 | else | 218 | else |
@@ -225,7 +225,7 @@ void LLXfer::sendPacket(S32 packet_num) | |||
225 | (S32)(mBufferLength - desired_read_position)); | 225 | (S32)(mBufferLength - desired_read_position)); |
226 | if (num_copy > 0) | 226 | if (num_copy > 0) |
227 | { | 227 | { |
228 | memcpy( | 228 | memcpy( /*Flawfinder: ignore*/ |
229 | fdata_buf + sizeof(S32), | 229 | fdata_buf + sizeof(S32), |
230 | &mBuffer[desired_read_position], | 230 | &mBuffer[desired_read_position], |
231 | num_copy); | 231 | num_copy); |
diff --git a/linden/indra/llmessage/llxfer_file.cpp b/linden/indra/llmessage/llxfer_file.cpp index 8d38644..2fec06b 100644 --- a/linden/indra/llmessage/llxfer_file.cpp +++ b/linden/indra/llmessage/llxfer_file.cpp | |||
@@ -413,8 +413,8 @@ U32 LLXfer_File::getXferTypeTag() | |||
413 | S32 copy_file(const char* from, const char* to) | 413 | S32 copy_file(const char* from, const char* to) |
414 | { | 414 | { |
415 | S32 rv = 0; | 415 | S32 rv = 0; |
416 | FILE* in = LLFile::fopen(from, "rb"); | 416 | FILE* in = LLFile::fopen(from, "rb"); /*Flawfinder: ignore*/ |
417 | FILE* out = LLFile::fopen(to, "wb"); | 417 | FILE* out = LLFile::fopen(to, "wb"); /*Flawfinder: ignore*/ |
418 | if(in && out) | 418 | if(in && out) |
419 | { | 419 | { |
420 | S32 read = 0; | 420 | S32 read = 0; |
diff --git a/linden/indra/llmessage/llxorcipher.cpp b/linden/indra/llmessage/llxorcipher.cpp index 7a72866..3c3f690 100644 --- a/linden/indra/llmessage/llxorcipher.cpp +++ b/linden/indra/llmessage/llxorcipher.cpp | |||
@@ -27,7 +27,8 @@ | |||
27 | 27 | ||
28 | #include "linden_common.h" | 28 | #include "linden_common.h" |
29 | 29 | ||
30 | #include "llcrypto.h" | 30 | #include "llxorcipher.h" |
31 | |||
31 | #include "llerror.h" | 32 | #include "llerror.h" |
32 | 33 | ||
33 | ///---------------------------------------------------------------------------- | 34 | ///---------------------------------------------------------------------------- |
@@ -63,25 +64,26 @@ LLXORCipher& LLXORCipher::operator=(const LLXORCipher& cipher) | |||
63 | return *this; | 64 | return *this; |
64 | } | 65 | } |
65 | 66 | ||
66 | BOOL LLXORCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | 67 | U32 LLXORCipher::encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) |
67 | { | 68 | { |
68 | if(!src || !src_len || !dst || !dst_len || !mPad) return FALSE; | 69 | if(!src || !src_len || !dst || !dst_len || !mPad) return 0; |
69 | U8* pad_end = mPad + mPadLen; | 70 | U8* pad_end = mPad + mPadLen; |
70 | while(src_len--) | 71 | U32 count = src_len; |
72 | while(count--) | ||
71 | { | 73 | { |
72 | *dst++ = *src++ ^ *mHead++; | 74 | *dst++ = *src++ ^ *mHead++; |
73 | if(mHead >= pad_end) mHead = mPad; | 75 | if(mHead >= pad_end) mHead = mPad; |
74 | } | 76 | } |
75 | return TRUE; | 77 | return src_len; |
76 | } | 78 | } |
77 | 79 | ||
78 | BOOL LLXORCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) | 80 | U32 LLXORCipher::decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) |
79 | { | 81 | { |
80 | // xor is a symetric cipher, thus, just call the other function. | 82 | // xor is a symetric cipher, thus, just call the other function. |
81 | return encrypt(src, src_len, dst, dst_len); | 83 | return encrypt(src, src_len, dst, dst_len); |
82 | } | 84 | } |
83 | 85 | ||
84 | U32 LLXORCipher::requiredEncryptionSpace(U32 len) | 86 | U32 LLXORCipher::requiredEncryptionSpace(U32 len) const |
85 | { | 87 | { |
86 | return len; | 88 | return len; |
87 | } | 89 | } |
diff --git a/linden/indra/llmessage/llcrypto.h b/linden/indra/llmessage/llxorcipher.h index b142d25..fbb879e 100644 --- a/linden/indra/llmessage/llcrypto.h +++ b/linden/indra/llmessage/llxorcipher.h | |||
@@ -1,8 +1,5 @@ | |||
1 | /** | 1 | /** |
2 | * @file llcrypto.h | 2 | * @file llxorcipher.h |
3 | * @brief llcrypto library module header. For now, all crypto classes | ||
4 | * are here, and as we grow the library, we can split these things | ||
5 | * out. | ||
6 | * | 3 | * |
7 | * Copyright (c) 2003-2007, Linden Research, Inc. | 4 | * Copyright (c) 2003-2007, Linden Research, Inc. |
8 | * | 5 | * |
@@ -27,50 +24,10 @@ | |||
27 | * COMPLETENESS OR PERFORMANCE. | 24 | * COMPLETENESS OR PERFORMANCE. |
28 | */ | 25 | */ |
29 | 26 | ||
30 | #ifndef LL_LLCRYPTO_H | 27 | #ifndef LLXORCIPHER_H |
31 | #define LL_LLCRYPTO_H | 28 | #define LLXORCIPHER_H |
32 | 29 | ||
33 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 30 | #include "llcipher.h" |
34 | // Class LLCipher | ||
35 | // | ||
36 | // Abstract base class for a cipher object. | ||
37 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
38 | |||
39 | class LLCipher | ||
40 | { | ||
41 | public: | ||
42 | virtual ~LLCipher() {} | ||
43 | |||
44 | // encrypt src and place result into dst. returns TRUE if | ||
45 | // encryption was successful, otherwise FALSE. | ||
46 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
47 | |||
48 | // decrypt src and place result into dst. returns TRUE if | ||
49 | // encryption was successful, otherwise FALSE. | ||
50 | virtual BOOL decrpyt(const U8* src, U32 src_len, U8* dst, U32 dst_len) = 0; | ||
51 | |||
52 | // returns the space required to encrypt for a unencrypted source | ||
53 | // buffer of length len. | ||
54 | virtual U32 requiredEncryptionSpace(U32 src_len) const = 0 ; | ||
55 | }; | ||
56 | |||
57 | |||
58 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
59 | // Class LLNullCipher | ||
60 | // | ||
61 | // A class which implements LLCipher, but does not transform src | ||
62 | // during encryption. | ||
63 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
64 | |||
65 | class LLNullCipher | ||
66 | { | ||
67 | public: | ||
68 | LLNullCipher() {} | ||
69 | virtual ~LLNullCipher() {} | ||
70 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
71 | virtual BOOL decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | ||
72 | virtual U32 requiredEncryptionSpace(U32 src_len); | ||
73 | }; | ||
74 | 31 | ||
75 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 32 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
76 | // Class LLXORCipher | 33 | // Class LLXORCipher |
@@ -78,7 +35,7 @@ public: | |||
78 | // Implementation of LLCipher which encrypts using a XOR pad. | 35 | // Implementation of LLCipher which encrypts using a XOR pad. |
79 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 36 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
80 | 37 | ||
81 | class LLXORCipher | 38 | class LLXORCipher : public LLCipher |
82 | { | 39 | { |
83 | public: | 40 | public: |
84 | LLXORCipher(const U8* pad, U32 pad_len); | 41 | LLXORCipher(const U8* pad, U32 pad_len); |
@@ -87,9 +44,9 @@ public: | |||
87 | LLXORCipher& operator=(const LLXORCipher& cipher); | 44 | LLXORCipher& operator=(const LLXORCipher& cipher); |
88 | 45 | ||
89 | // Cipher functions | 46 | // Cipher functions |
90 | virtual BOOL encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | 47 | /*virtual*/ U32 encrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); |
91 | virtual BOOL decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); | 48 | /*virtual*/ U32 decrypt(const U8* src, U32 src_len, U8* dst, U32 dst_len); |
92 | virtual U32 requiredEncryptionSpace(U32 src_len); | 49 | /*virtual*/ U32 requiredEncryptionSpace(U32 src_len) const; |
93 | 50 | ||
94 | // special syntactic-sugar since xor can be performed in place. | 51 | // special syntactic-sugar since xor can be performed in place. |
95 | BOOL encrypt(U8* buf, U32 len) { return encrypt((const U8*)buf, len, buf, len); } | 52 | BOOL encrypt(U8* buf, U32 len) { return encrypt((const U8*)buf, len, buf, len); } |
@@ -108,4 +65,4 @@ protected: | |||
108 | U32 mPadLen; | 65 | U32 mPadLen; |
109 | }; | 66 | }; |
110 | 67 | ||
111 | #endif // LL_LLCRYPTO_H | 68 | #endif |
diff --git a/linden/indra/llmessage/message.cpp b/linden/indra/llmessage/message.cpp index 5baefff..2e7cb6a 100644 --- a/linden/indra/llmessage/message.cpp +++ b/linden/indra/llmessage/message.cpp | |||
@@ -987,7 +987,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
987 | 987 | ||
988 | LLMessageVariable var; | 988 | LLMessageVariable var; |
989 | char var_name[MAX_MESSAGE_INTERNAL_NAME_SIZE]; /* Flawfinder: ignore */ | 989 | char var_name[MAX_MESSAGE_INTERNAL_NAME_SIZE]; /* Flawfinder: ignore */ |
990 | char formatString[MAX_MESSAGE_INTERNAL_NAME_SIZE]; | 990 | char formatString[MAX_MESSAGE_INTERNAL_NAME_SIZE]; /* Flawfinder: ignore */ |
991 | 991 | ||
992 | FILE* messagefilep = NULL; | 992 | FILE* messagefilep = NULL; |
993 | mMessageFileChecksum = 0; | 993 | mMessageFileChecksum = 0; |
@@ -995,14 +995,19 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
995 | S32 checksum_offset = 0; | 995 | S32 checksum_offset = 0; |
996 | char* checkp = NULL; | 996 | char* checkp = NULL; |
997 | 997 | ||
998 | snprintf(formatString, sizeof(formatString), "%%%ds", MAX_MESSAGE_INTERNAL_NAME_SIZE); | 998 | // scanf needs 1 byte more than width, thus the MAX_... -1. |
999 | messagefilep = LLFile::fopen(filename, "r"); | 999 | snprintf( /* Flawfinder: ignore */ |
1000 | formatString, | ||
1001 | sizeof(formatString), | ||
1002 | "%%%ds", | ||
1003 | MAX_MESSAGE_INTERNAL_NAME_SIZE - 1); | ||
1004 | messagefilep = LLFile::fopen(filename, "r"); /* Flawfinder: ignore */ | ||
1000 | if (messagefilep) | 1005 | if (messagefilep) |
1001 | { | 1006 | { |
1002 | // mName = gMessageStringTable.getString(filename); | 1007 | // mName = gMessageStringTable.getString(filename); |
1003 | 1008 | ||
1004 | fseek(messagefilep, 0L, SEEK_SET ); | 1009 | fseek(messagefilep, 0L, SEEK_SET ); |
1005 | while(fscanf(messagefilep, formatString, token) != EOF) | 1010 | while(fscanf(messagefilep, formatString, token) != EOF) /* Flawfinder: ignore */ |
1006 | { | 1011 | { |
1007 | // skip comments | 1012 | // skip comments |
1008 | if (token[0] == '/') | 1013 | if (token[0] == '/') |
@@ -1132,7 +1137,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1132 | b_template = FALSE; | 1137 | b_template = FALSE; |
1133 | 1138 | ||
1134 | // name first | 1139 | // name first |
1135 | if (fscanf(messagefilep, formatString, template_name) == EOF) | 1140 | if (fscanf(messagefilep, formatString, template_name) == EOF) /* Flawfinder: ignore */ |
1136 | { | 1141 | { |
1137 | // oops, file ended | 1142 | // oops, file ended |
1138 | llerrs << "Expected message template name, but file ended" | 1143 | llerrs << "Expected message template name, but file ended" |
@@ -1164,7 +1169,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1164 | } | 1169 | } |
1165 | 1170 | ||
1166 | // ok, now get Frequency ("High", "Medium", or "Low") | 1171 | // ok, now get Frequency ("High", "Medium", or "Low") |
1167 | if (fscanf(messagefilep, formatString, token) == EOF) | 1172 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1168 | { | 1173 | { |
1169 | // oops, file ended | 1174 | // oops, file ended |
1170 | llerrs << "Expected message template frequency, found EOF." | 1175 | llerrs << "Expected message template frequency, found EOF." |
@@ -1245,7 +1250,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1245 | else if (!strcmp(token, "Fixed")) | 1250 | else if (!strcmp(token, "Fixed")) |
1246 | { | 1251 | { |
1247 | U32 message_num = 0; | 1252 | U32 message_num = 0; |
1248 | if (fscanf(messagefilep, formatString, token) == EOF) | 1253 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1249 | { | 1254 | { |
1250 | // oops, file ended | 1255 | // oops, file ended |
1251 | llerrs << "Expected message template number (fixed)," | 1256 | llerrs << "Expected message template number (fixed)," |
@@ -1279,7 +1284,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1279 | } | 1284 | } |
1280 | 1285 | ||
1281 | // Now get trust ("Trusted", "NotTrusted") | 1286 | // Now get trust ("Trusted", "NotTrusted") |
1282 | if (fscanf(messagefilep, formatString, token) == EOF) | 1287 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1283 | { | 1288 | { |
1284 | // File ended | 1289 | // File ended |
1285 | llerrs << "Expected message template " | 1290 | llerrs << "Expected message template " |
@@ -1316,7 +1321,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1316 | } | 1321 | } |
1317 | 1322 | ||
1318 | // get encoding | 1323 | // get encoding |
1319 | if (fscanf(messagefilep, formatString, token) == EOF) | 1324 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1320 | { | 1325 | { |
1321 | // File ended | 1326 | // File ended |
1322 | llerrs << "Expected message encoding, but file ended." | 1327 | llerrs << "Expected message encoding, but file ended." |
@@ -1362,7 +1367,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1362 | // ok, need to pull header info | 1367 | // ok, need to pull header info |
1363 | 1368 | ||
1364 | // name first | 1369 | // name first |
1365 | if (fscanf(messagefilep, formatString, block_name) == EOF) | 1370 | if (fscanf(messagefilep, formatString, block_name) == EOF) /* Flawfinder: ignore */ |
1366 | { | 1371 | { |
1367 | // oops, file ended | 1372 | // oops, file ended |
1368 | llerrs << "Expected block name, but file ended" << llendl; | 1373 | llerrs << "Expected block name, but file ended" << llendl; |
@@ -1390,7 +1395,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1390 | } | 1395 | } |
1391 | 1396 | ||
1392 | // now, block type ("Single", "Multiple", or "Variable") | 1397 | // now, block type ("Single", "Multiple", or "Variable") |
1393 | if (fscanf(messagefilep, formatString, token) == EOF) | 1398 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1394 | { | 1399 | { |
1395 | // oops, file ended | 1400 | // oops, file ended |
1396 | llerrs << "Expected block type, but file ended." << llendl; | 1401 | llerrs << "Expected block type, but file ended." << llendl; |
@@ -1415,7 +1420,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1415 | else if (!strcmp(token, "Multiple")) | 1420 | else if (!strcmp(token, "Multiple")) |
1416 | { | 1421 | { |
1417 | // need to get the number of repeats | 1422 | // need to get the number of repeats |
1418 | if (fscanf(messagefilep, formatString, token) == EOF) | 1423 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1419 | { | 1424 | { |
1420 | // oops, file ended | 1425 | // oops, file ended |
1421 | llerrs << "Expected block multiple count," | 1426 | llerrs << "Expected block multiple count," |
@@ -1471,7 +1476,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1471 | // ok, need to pull header info | 1476 | // ok, need to pull header info |
1472 | 1477 | ||
1473 | // name first | 1478 | // name first |
1474 | if (fscanf(messagefilep, formatString, var_name) == EOF) | 1479 | if (fscanf(messagefilep, formatString, var_name) == EOF) /* Flawfinder: ignore */ |
1475 | { | 1480 | { |
1476 | // oops, file ended | 1481 | // oops, file ended |
1477 | llerrs << "Expected variable name, but file ended." | 1482 | llerrs << "Expected variable name, but file ended." |
@@ -1500,7 +1505,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1500 | } | 1505 | } |
1501 | 1506 | ||
1502 | // now, variable type ("Fixed" or "Variable") | 1507 | // now, variable type ("Fixed" or "Variable") |
1503 | if (fscanf(messagefilep, formatString, token) == EOF) | 1508 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1504 | { | 1509 | { |
1505 | // oops, file ended | 1510 | // oops, file ended |
1506 | llerrs << "Expected variable type, but file ended" | 1511 | llerrs << "Expected variable type, but file ended" |
@@ -1594,7 +1599,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1594 | else if (!strcmp(token, "Fixed")) | 1599 | else if (!strcmp(token, "Fixed")) |
1595 | { | 1600 | { |
1596 | // need to get the variable size | 1601 | // need to get the variable size |
1597 | if (fscanf(messagefilep, formatString, token) == EOF) | 1602 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1598 | { | 1603 | { |
1599 | // oops, file ended | 1604 | // oops, file ended |
1600 | llerrs << "Expected variable size, but file ended" | 1605 | llerrs << "Expected variable size, but file ended" |
@@ -1627,7 +1632,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1627 | else if (!strcmp(token, "Variable")) | 1632 | else if (!strcmp(token, "Variable")) |
1628 | { | 1633 | { |
1629 | // need to get the variable size | 1634 | // need to get the variable size |
1630 | if (fscanf(messagefilep, formatString, token) == EOF) | 1635 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1631 | { | 1636 | { |
1632 | // oops, file ended | 1637 | // oops, file ended |
1633 | llerrs << "Expected variable size, but file ended" | 1638 | llerrs << "Expected variable size, but file ended" |
@@ -1676,7 +1681,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) | |||
1676 | if (!strcmp(token, "version")) | 1681 | if (!strcmp(token, "version")) |
1677 | { | 1682 | { |
1678 | // version number | 1683 | // version number |
1679 | if (fscanf(messagefilep, formatString, token) == EOF) | 1684 | if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ |
1680 | { | 1685 | { |
1681 | // oops, file ended | 1686 | // oops, file ended |
1682 | llerrs << "Expected version number, but file ended" | 1687 | llerrs << "Expected version number, but file ended" |
@@ -1815,14 +1820,27 @@ BOOL LLMessageSystem::checkMessages( S64 frame_count ) | |||
1815 | else | 1820 | else |
1816 | { | 1821 | { |
1817 | LLHost host; | 1822 | LLHost host; |
1818 | LLCircuitData *cdp; | 1823 | LLCircuitData* cdp; |
1819 | 1824 | ||
1820 | // note if packet acks are appended. | 1825 | // note if packet acks are appended. |
1821 | if(buffer[0] & LL_ACK_FLAG) | 1826 | if(buffer[0] & LL_ACK_FLAG) |
1822 | { | 1827 | { |
1823 | acks += buffer[--mReceiveSize]; | 1828 | acks += buffer[--mReceiveSize]; |
1824 | true_rcv_size = mReceiveSize; | 1829 | true_rcv_size = mReceiveSize; |
1825 | mReceiveSize -= acks * sizeof(TPACKETID); | 1830 | if(mReceiveSize >= ((S32)(acks * sizeof(TPACKETID) + LL_MINIMUM_VALID_PACKET_SIZE))) |
1831 | { | ||
1832 | mReceiveSize -= acks * sizeof(TPACKETID); | ||
1833 | } | ||
1834 | else | ||
1835 | { | ||
1836 | // mal-formed packet. ignore it and continue with | ||
1837 | // the next one | ||
1838 | llwarns << "Malformed packet received. Packet size " | ||
1839 | << mReceiveSize << " with invalid no. of acks " << acks | ||
1840 | << llendl; | ||
1841 | valid_packet = FALSE; | ||
1842 | continue; | ||
1843 | } | ||
1826 | } | 1844 | } |
1827 | 1845 | ||
1828 | // process the message as normal | 1846 | // process the message as normal |
@@ -2734,7 +2752,7 @@ void LLMessageSystem::buildMessage() | |||
2734 | temp_block_number = (U8)mbci->mBlockNumber; | 2752 | temp_block_number = (U8)mbci->mBlockNumber; |
2735 | if ((S32)(mSendSize + sizeof(U8)) < MAX_BUFFER_SIZE) | 2753 | if ((S32)(mSendSize + sizeof(U8)) < MAX_BUFFER_SIZE) |
2736 | { | 2754 | { |
2737 | memcpy(&mSendBuffer[mSendSize], &temp_block_number, sizeof(U8)); | 2755 | memcpy(&mSendBuffer[mSendSize], &temp_block_number, sizeof(U8)); /* Flawfinder: ignore */ |
2738 | mSendSize += sizeof(U8); | 2756 | mSendSize += sizeof(U8); |
2739 | } | 2757 | } |
2740 | else | 2758 | else |
@@ -2811,7 +2829,7 @@ void LLMessageSystem::buildMessage() | |||
2811 | { | 2829 | { |
2812 | if(mSendSize + mvci.getSize() < (S32)sizeof(mSendBuffer)) | 2830 | if(mSendSize + mvci.getSize() < (S32)sizeof(mSendBuffer)) |
2813 | { | 2831 | { |
2814 | memcpy( | 2832 | memcpy( /* Flawfinder: ignore */ |
2815 | &mSendBuffer[mSendSize], | 2833 | &mSendBuffer[mSendSize], |
2816 | mvci.getData(), | 2834 | mvci.getData(), |
2817 | mvci.getSize()); | 2835 | mvci.getSize()); |
@@ -3077,7 +3095,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host) | |||
3077 | 3095 | ||
3078 | if((S32)(buffer_length + sizeof(TPACKETID)) < MAX_BUFFER_SIZE) | 3096 | if((S32)(buffer_length + sizeof(TPACKETID)) < MAX_BUFFER_SIZE) |
3079 | { | 3097 | { |
3080 | memcpy(&buf_ptr[buffer_length], &packet_id, sizeof(TPACKETID)); | 3098 | memcpy(&buf_ptr[buffer_length], &packet_id, sizeof(TPACKETID)); /* Flawfinder: ignore */ |
3081 | // Do the accounting | 3099 | // Do the accounting |
3082 | buffer_length += sizeof(TPACKETID); | 3100 | buffer_length += sizeof(TPACKETID); |
3083 | } | 3101 | } |
@@ -3185,7 +3203,7 @@ BOOL LLMessageSystem::decodeTemplate( | |||
3185 | // it appears that if there is a NULL in the message #, it won't copy it.... | 3203 | // it appears that if there is a NULL in the message #, it won't copy it.... |
3186 | // what was the goal? | 3204 | // what was the goal? |
3187 | //if(header[2]) | 3205 | //if(header[2]) |
3188 | memcpy(&message_id_U16, &header[2], 2); | 3206 | memcpy(&message_id_U16, &header[2], 2); /* Flawfinder: ignore */ |
3189 | 3207 | ||
3190 | // dependant on endian-ness: | 3208 | // dependant on endian-ness: |
3191 | // U32 temp = (255 << 24) | (255 << 16) | header[2]; | 3209 | // U32 temp = (255 << 24) | (255 << 16) | header[2]; |
@@ -3343,7 +3361,7 @@ BOOL LLMessageSystem::decodeData(const U8* buffer, const LLHost& sender ) | |||
3343 | 3361 | ||
3344 | // create base working data set | 3362 | // create base working data set |
3345 | mCurrentRMessageData = new LLMsgData(mCurrentRMessageTemplate->mName); | 3363 | mCurrentRMessageData = new LLMsgData(mCurrentRMessageTemplate->mName); |
3346 | 3364 | ||
3347 | // loop through the template building the data structure as we go | 3365 | // loop through the template building the data structure as we go |
3348 | for (LLMessageTemplate::message_block_map_t::iterator iter = mCurrentRMessageTemplate->mMemberBlocks.begin(); | 3366 | for (LLMessageTemplate::message_block_map_t::iterator iter = mCurrentRMessageTemplate->mMemberBlocks.begin(); |
3349 | iter != mCurrentRMessageTemplate->mMemberBlocks.end(); iter++) | 3367 | iter != mCurrentRMessageTemplate->mMemberBlocks.end(); iter++) |
@@ -3596,7 +3614,7 @@ void LLMessageSystem::getDataFast(const char *blockname, const char *varname, vo | |||
3596 | ((U32*)datap)[1] = ((U32*)vardata.getData())[1]; | 3614 | ((U32*)datap)[1] = ((U32*)vardata.getData())[1]; |
3597 | break; | 3615 | break; |
3598 | default: | 3616 | default: |
3599 | memcpy(datap, vardata.getData(), vardata_size); | 3617 | memcpy(datap, vardata.getData(), vardata_size); /* Flawfinder: ignore */ |
3600 | break; | 3618 | break; |
3601 | } | 3619 | } |
3602 | } | 3620 | } |
@@ -3608,7 +3626,7 @@ void LLMessageSystem::getDataFast(const char *blockname, const char *varname, vo | |||
3608 | << " but truncated to max size of " << max_size | 3626 | << " but truncated to max size of " << max_size |
3609 | << llendl; | 3627 | << llendl; |
3610 | 3628 | ||
3611 | memcpy(datap, vardata.getData(), max_size); | 3629 | memcpy(datap, vardata.getData(), max_size); /* Flawfinder: ignore */ |
3612 | } | 3630 | } |
3613 | } | 3631 | } |
3614 | 3632 | ||
@@ -4403,33 +4421,6 @@ void process_secured_template_checksum_request(LLMessageSystem* msg, void**) | |||
4403 | send_template_reply(msg, token); | 4421 | send_template_reply(msg, token); |
4404 | } | 4422 | } |
4405 | 4423 | ||
4406 | void process_log_control(LLMessageSystem* msg, void**) | ||
4407 | { | ||
4408 | U8 level; | ||
4409 | U32 mask; | ||
4410 | BOOL time; | ||
4411 | BOOL location; | ||
4412 | BOOL remote_infos; | ||
4413 | |||
4414 | msg->getU8Fast(_PREHASH_Options, _PREHASH_Level, level); | ||
4415 | msg->getU32Fast(_PREHASH_Options, _PREHASH_Mask, mask); | ||
4416 | msg->getBOOLFast(_PREHASH_Options, _PREHASH_Time, time); | ||
4417 | msg->getBOOLFast(_PREHASH_Options, _PREHASH_Location, location); | ||
4418 | msg->getBOOLFast(_PREHASH_Options, _PREHASH_RemoteInfos, remote_infos); | ||
4419 | |||
4420 | gErrorStream.setLevel(LLErrorStream::ELevel(level)); | ||
4421 | gErrorStream.setDebugMask(mask); | ||
4422 | gErrorStream.setTime(time); | ||
4423 | gErrorStream.setPrintLocation(location); | ||
4424 | gErrorStream.setElevatedRemote(remote_infos); | ||
4425 | |||
4426 | llinfos << "Logging set to level " << gErrorStream.getLevel() | ||
4427 | << " mask " << std::hex << gErrorStream.getDebugMask() << std::dec | ||
4428 | << " time " << gErrorStream.getTime() | ||
4429 | << " loc " << gErrorStream.getPrintLocation() | ||
4430 | << llendl; | ||
4431 | } | ||
4432 | |||
4433 | void process_log_messages(LLMessageSystem* msg, void**) | 4424 | void process_log_messages(LLMessageSystem* msg, void**) |
4434 | { | 4425 | { |
4435 | U8 log_message; | 4426 | U8 log_message; |
@@ -4475,7 +4466,7 @@ void process_create_trusted_circuit(LLMessageSystem *msg, void **) | |||
4475 | return; | 4466 | return; |
4476 | } | 4467 | } |
4477 | 4468 | ||
4478 | char their_digest[MD5HEX_STR_SIZE]; | 4469 | char their_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ |
4479 | S32 size = msg->getSizeFast(_PREHASH_DataBlock, _PREHASH_Digest); | 4470 | S32 size = msg->getSizeFast(_PREHASH_DataBlock, _PREHASH_Digest); |
4480 | if(size != MD5HEX_STR_BYTES) | 4471 | if(size != MD5HEX_STR_BYTES) |
4481 | { | 4472 | { |
@@ -4555,7 +4546,7 @@ void encrypt_template(const char *src_name, const char *dest_name) | |||
4555 | BOOL decrypt_template(const char *src_name, const char *dest_name) | 4546 | BOOL decrypt_template(const char *src_name, const char *dest_name) |
4556 | { | 4547 | { |
4557 | S32 buf_length = LL_ENCRYPT_BUF_LENGTH; | 4548 | S32 buf_length = LL_ENCRYPT_BUF_LENGTH; |
4558 | char buf[LL_ENCRYPT_BUF_LENGTH]; | 4549 | char buf[LL_ENCRYPT_BUF_LENGTH]; /* Flawfinder: ignore */ |
4559 | 4550 | ||
4560 | FILE* infp = NULL; | 4551 | FILE* infp = NULL; |
4561 | FILE* outfp = NULL; | 4552 | FILE* outfp = NULL; |
@@ -4570,7 +4561,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) | |||
4570 | goto exit; | 4561 | goto exit; |
4571 | } | 4562 | } |
4572 | 4563 | ||
4573 | infp = LLFile::fopen(src_name,"rb"); | 4564 | infp = LLFile::fopen(src_name,"rb"); /* Flawfinder: ignore */ |
4574 | if (!infp) | 4565 | if (!infp) |
4575 | { | 4566 | { |
4576 | llwarns << "could not open " << src_name << " for reading" << llendl; | 4567 | llwarns << "could not open " << src_name << " for reading" << llendl; |
@@ -4583,7 +4574,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) | |||
4583 | goto exit; | 4574 | goto exit; |
4584 | } | 4575 | } |
4585 | 4576 | ||
4586 | outfp = LLFile::fopen(dest_name,"w+b"); | 4577 | outfp = LLFile::fopen(dest_name,"w+b"); /* Flawfinder: ignore */ |
4587 | if (!outfp) | 4578 | if (!outfp) |
4588 | { | 4579 | { |
4589 | llwarns << "could not open " << src_name << " for writing" << llendl; | 4580 | llwarns << "could not open " << src_name << " for writing" << llendl; |
@@ -4618,7 +4609,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) | |||
4618 | void dump_prehash_files() | 4609 | void dump_prehash_files() |
4619 | { | 4610 | { |
4620 | U32 i; | 4611 | U32 i; |
4621 | FILE *fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); | 4612 | FILE* fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); /* Flawfinder: ignore */ |
4622 | if (fp) | 4613 | if (fp) |
4623 | { | 4614 | { |
4624 | fprintf( | 4615 | fprintf( |
@@ -4650,7 +4641,7 @@ void dump_prehash_files() | |||
4650 | fprintf(fp, "\n\n#endif\n"); | 4641 | fprintf(fp, "\n\n#endif\n"); |
4651 | fclose(fp); | 4642 | fclose(fp); |
4652 | } | 4643 | } |
4653 | fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); | 4644 | fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); /* Flawfinder: ignore */ |
4654 | if (fp) | 4645 | if (fp) |
4655 | { | 4646 | { |
4656 | fprintf( | 4647 | fprintf( |
@@ -4750,7 +4741,6 @@ BOOL start_messaging_system( | |||
4750 | gMessageSystem->setHandlerFuncFast(_PREHASH_PacketAck, process_packet_ack, NULL); | 4741 | gMessageSystem->setHandlerFuncFast(_PREHASH_PacketAck, process_packet_ack, NULL); |
4751 | gMessageSystem->setHandlerFuncFast(_PREHASH_TemplateChecksumRequest, process_template_checksum_request, NULL); | 4742 | gMessageSystem->setHandlerFuncFast(_PREHASH_TemplateChecksumRequest, process_template_checksum_request, NULL); |
4752 | gMessageSystem->setHandlerFuncFast(_PREHASH_SecuredTemplateChecksumRequest, process_secured_template_checksum_request, NULL); | 4743 | gMessageSystem->setHandlerFuncFast(_PREHASH_SecuredTemplateChecksumRequest, process_secured_template_checksum_request, NULL); |
4753 | gMessageSystem->setHandlerFuncFast(_PREHASH_LogControl, process_log_control, NULL); | ||
4754 | gMessageSystem->setHandlerFuncFast(_PREHASH_LogMessages, process_log_messages, NULL); | 4744 | gMessageSystem->setHandlerFuncFast(_PREHASH_LogMessages, process_log_messages, NULL); |
4755 | gMessageSystem->setHandlerFuncFast(_PREHASH_CreateTrustedCircuit, | 4745 | gMessageSystem->setHandlerFuncFast(_PREHASH_CreateTrustedCircuit, |
4756 | process_create_trusted_circuit, | 4746 | process_create_trusted_circuit, |
@@ -5565,13 +5555,21 @@ void LLMessageSystem::getUUID(const char *block, const char *var, LLUUID &u, S32 | |||
5565 | getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), u.mData, sizeof(u.mData), blocknum); | 5555 | getDataFast(gMessageStringTable.getString(block), gMessageStringTable.getString(var), u.mData, sizeof(u.mData), blocknum); |
5566 | } | 5556 | } |
5567 | 5557 | ||
5568 | bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 number, const LLUUID &id1, const LLUUID &id2) const | 5558 | bool LLMessageSystem::generateDigestForNumberAndUUIDs( |
5559 | char* digest, | ||
5560 | const U32 number, | ||
5561 | const LLUUID& id1, | ||
5562 | const LLUUID& id2) const | ||
5569 | { | 5563 | { |
5564 | // *NOTE: This method is needlessly inefficient. Instead of | ||
5565 | // calling LLUUID::asString, it should just call | ||
5566 | // LLUUID::toString(). | ||
5567 | |||
5570 | const char *colon = ":"; | 5568 | const char *colon = ":"; |
5571 | char tbuf[16]; /* Flawfinder: ignore */ | 5569 | char tbuf[16]; /* Flawfinder: ignore */ |
5572 | LLMD5 d; | 5570 | LLMD5 d; |
5573 | LLString id1string = id1.getString(); | 5571 | std::string id1string = id1.asString(); |
5574 | LLString id2string = id2.getString(); | 5572 | std::string id2string = id2.asString(); |
5575 | std::string shared_secret = get_shared_secret(); | 5573 | std::string shared_secret = get_shared_secret(); |
5576 | unsigned char * secret = (unsigned char*)shared_secret.c_str(); | 5574 | unsigned char * secret = (unsigned char*)shared_secret.c_str(); |
5577 | unsigned char * id1str = (unsigned char*)id1string.c_str(); | 5575 | unsigned char * id1str = (unsigned char*)id1string.c_str(); |
@@ -5581,7 +5579,7 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 nu | |||
5581 | 5579 | ||
5582 | if( secret != NULL) | 5580 | if( secret != NULL) |
5583 | { | 5581 | { |
5584 | d.update(secret, (U32)strlen((char *) secret)); | 5582 | d.update(secret, (U32)strlen((char *) secret)); /* Flawfinder: ignore */ |
5585 | } | 5583 | } |
5586 | 5584 | ||
5587 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ | 5585 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ |
@@ -5592,13 +5590,13 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 nu | |||
5592 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ | 5590 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ |
5593 | if( (char*) id1str != NULL) | 5591 | if( (char*) id1str != NULL) |
5594 | { | 5592 | { |
5595 | d.update(id1str, (U32)strlen((char *) id1str)); | 5593 | d.update(id1str, (U32)strlen((char *) id1str)); /* Flawfinder: ignore */ |
5596 | } | 5594 | } |
5597 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ | 5595 | d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ |
5598 | 5596 | ||
5599 | if( (char*) id2str != NULL) | 5597 | if( (char*) id2str != NULL) |
5600 | { | 5598 | { |
5601 | d.update(id2str, (U32)strlen((char *) id2str)); | 5599 | d.update(id2str, (U32)strlen((char *) id2str)); /* Flawfinder: ignore */ |
5602 | } | 5600 | } |
5603 | 5601 | ||
5604 | d.finalize(); | 5602 | d.finalize(); |
diff --git a/linden/indra/llmessage/message.h b/linden/indra/llmessage/message.h index df062e7..5cc3ec1 100644 --- a/linden/indra/llmessage/message.h +++ b/linden/indra/llmessage/message.h | |||
@@ -206,6 +206,8 @@ class LLMessagePollInfo; | |||
206 | 206 | ||
207 | class LLMessageSystem | 207 | class LLMessageSystem |
208 | { | 208 | { |
209 | LOG_CLASS(LLMessageSystem); | ||
210 | |||
209 | public: | 211 | public: |
210 | U8 mSendBuffer[MAX_BUFFER_SIZE]; | 212 | U8 mSendBuffer[MAX_BUFFER_SIZE]; |
211 | // Encoded send buffer needs to be slightly larger since the zero | 213 | // Encoded send buffer needs to be slightly larger since the zero |
@@ -438,6 +440,7 @@ public: | |||
438 | void addStringFast( const char* varname, const std::string& s); // typed, checks storage space | 440 | void addStringFast( const char* varname, const std::string& s); // typed, checks storage space |
439 | void addString( const char* varname, const std::string& s); // typed, checks storage space | 441 | void addString( const char* varname, const std::string& s); // typed, checks storage space |
440 | 442 | ||
443 | TPACKETID getCurrentRecvPacketID() { return mCurrentRecvPacketID; } | ||
441 | S32 getCurrentSendTotal() const { return mCurrentSendTotal; } | 444 | S32 getCurrentSendTotal() const { return mCurrentSendTotal; } |
442 | 445 | ||
443 | // This method checks for current send total and returns true if | 446 | // This method checks for current send total and returns true if |
@@ -776,7 +779,6 @@ BOOL start_messaging_system( | |||
776 | void end_messaging_system(); | 779 | void end_messaging_system(); |
777 | 780 | ||
778 | void null_message_callback(LLMessageSystem *msg, void **data); | 781 | void null_message_callback(LLMessageSystem *msg, void **data); |
779 | void process_log_control(LLMessageSystem* msg, void**); | ||
780 | 782 | ||
781 | // | 783 | // |
782 | // Inlines | 784 | // Inlines |
diff --git a/linden/indra/llmessage/message_prehash.cpp b/linden/indra/llmessage/message_prehash.cpp index 2753c87..ef01c82 100644 --- a/linden/indra/llmessage/message_prehash.cpp +++ b/linden/indra/llmessage/message_prehash.cpp | |||
@@ -508,7 +508,6 @@ char * _PREHASH_NVPair; | |||
508 | char * _PREHASH_ObjectSpinStart; | 508 | char * _PREHASH_ObjectSpinStart; |
509 | char * _PREHASH_UseEstateSun; | 509 | char * _PREHASH_UseEstateSun; |
510 | char * _PREHASH_LogoutBlock; | 510 | char * _PREHASH_LogoutBlock; |
511 | char * _PREHASH_RelayLogControl; | ||
512 | char * _PREHASH_RegionID; | 511 | char * _PREHASH_RegionID; |
513 | char * _PREHASH_Creator; | 512 | char * _PREHASH_Creator; |
514 | char * _PREHASH_ProposalText; | 513 | char * _PREHASH_ProposalText; |
@@ -1313,7 +1312,6 @@ char * _PREHASH_AssetBlock; | |||
1313 | char * _PREHASH_AcceptNotices; | 1312 | char * _PREHASH_AcceptNotices; |
1314 | char * _PREHASH_SetGroupAcceptNotices; | 1313 | char * _PREHASH_SetGroupAcceptNotices; |
1315 | char * _PREHASH_CloseCircuit; | 1314 | char * _PREHASH_CloseCircuit; |
1316 | char * _PREHASH_LogControl; | ||
1317 | char * _PREHASH_TeleportFinish; | 1315 | char * _PREHASH_TeleportFinish; |
1318 | char * _PREHASH_PathRevolutions; | 1316 | char * _PREHASH_PathRevolutions; |
1319 | char * _PREHASH_ClassifiedInfoReply; | 1317 | char * _PREHASH_ClassifiedInfoReply; |
@@ -1982,7 +1980,6 @@ void init_prehash_data() | |||
1982 | _PREHASH_ObjectSpinStart = gMessageStringTable.getString("ObjectSpinStart"); | 1980 | _PREHASH_ObjectSpinStart = gMessageStringTable.getString("ObjectSpinStart"); |
1983 | _PREHASH_UseEstateSun = gMessageStringTable.getString("UseEstateSun"); | 1981 | _PREHASH_UseEstateSun = gMessageStringTable.getString("UseEstateSun"); |
1984 | _PREHASH_LogoutBlock = gMessageStringTable.getString("LogoutBlock"); | 1982 | _PREHASH_LogoutBlock = gMessageStringTable.getString("LogoutBlock"); |
1985 | _PREHASH_RelayLogControl = gMessageStringTable.getString("RelayLogControl"); | ||
1986 | _PREHASH_RegionID = gMessageStringTable.getString("RegionID"); | 1983 | _PREHASH_RegionID = gMessageStringTable.getString("RegionID"); |
1987 | _PREHASH_Creator = gMessageStringTable.getString("Creator"); | 1984 | _PREHASH_Creator = gMessageStringTable.getString("Creator"); |
1988 | _PREHASH_ProposalText = gMessageStringTable.getString("ProposalText"); | 1985 | _PREHASH_ProposalText = gMessageStringTable.getString("ProposalText"); |
@@ -2787,7 +2784,6 @@ void init_prehash_data() | |||
2787 | _PREHASH_AcceptNotices = gMessageStringTable.getString("AcceptNotices"); | 2784 | _PREHASH_AcceptNotices = gMessageStringTable.getString("AcceptNotices"); |
2788 | _PREHASH_SetGroupAcceptNotices = gMessageStringTable.getString("SetGroupAcceptNotices"); | 2785 | _PREHASH_SetGroupAcceptNotices = gMessageStringTable.getString("SetGroupAcceptNotices"); |
2789 | _PREHASH_CloseCircuit = gMessageStringTable.getString("CloseCircuit"); | 2786 | _PREHASH_CloseCircuit = gMessageStringTable.getString("CloseCircuit"); |
2790 | _PREHASH_LogControl = gMessageStringTable.getString("LogControl"); | ||
2791 | _PREHASH_TeleportFinish = gMessageStringTable.getString("TeleportFinish"); | 2787 | _PREHASH_TeleportFinish = gMessageStringTable.getString("TeleportFinish"); |
2792 | _PREHASH_PathRevolutions = gMessageStringTable.getString("PathRevolutions"); | 2788 | _PREHASH_PathRevolutions = gMessageStringTable.getString("PathRevolutions"); |
2793 | _PREHASH_ClassifiedInfoReply = gMessageStringTable.getString("ClassifiedInfoReply"); | 2789 | _PREHASH_ClassifiedInfoReply = gMessageStringTable.getString("ClassifiedInfoReply"); |
diff --git a/linden/indra/llmessage/message_prehash.h b/linden/indra/llmessage/message_prehash.h index aee8045..9cb4884 100644 --- a/linden/indra/llmessage/message_prehash.h +++ b/linden/indra/llmessage/message_prehash.h | |||
@@ -508,7 +508,6 @@ extern char * _PREHASH_NVPair; | |||
508 | extern char * _PREHASH_ObjectSpinStart; | 508 | extern char * _PREHASH_ObjectSpinStart; |
509 | extern char * _PREHASH_UseEstateSun; | 509 | extern char * _PREHASH_UseEstateSun; |
510 | extern char * _PREHASH_LogoutBlock; | 510 | extern char * _PREHASH_LogoutBlock; |
511 | extern char * _PREHASH_RelayLogControl; | ||
512 | extern char * _PREHASH_RegionID; | 511 | extern char * _PREHASH_RegionID; |
513 | extern char * _PREHASH_Creator; | 512 | extern char * _PREHASH_Creator; |
514 | extern char * _PREHASH_ProposalText; | 513 | extern char * _PREHASH_ProposalText; |
@@ -1313,7 +1312,6 @@ extern char * _PREHASH_AssetBlock; | |||
1313 | extern char * _PREHASH_AcceptNotices; | 1312 | extern char * _PREHASH_AcceptNotices; |
1314 | extern char * _PREHASH_SetGroupAcceptNotices; | 1313 | extern char * _PREHASH_SetGroupAcceptNotices; |
1315 | extern char * _PREHASH_CloseCircuit; | 1314 | extern char * _PREHASH_CloseCircuit; |
1316 | extern char * _PREHASH_LogControl; | ||
1317 | extern char * _PREHASH_TeleportFinish; | 1315 | extern char * _PREHASH_TeleportFinish; |
1318 | extern char * _PREHASH_PathRevolutions; | 1316 | extern char * _PREHASH_PathRevolutions; |
1319 | extern char * _PREHASH_ClassifiedInfoReply; | 1317 | extern char * _PREHASH_ClassifiedInfoReply; |
diff --git a/linden/indra/llmessage/message_string_table.cpp b/linden/indra/llmessage/message_string_table.cpp index 88e073b..7fea048 100644 --- a/linden/indra/llmessage/message_string_table.cpp +++ b/linden/indra/llmessage/message_string_table.cpp | |||
@@ -76,7 +76,7 @@ char* LLMessageStringTable::getString(const char *str) | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | // not found, so add! | 78 | // not found, so add! |
79 | strncpy(mString[hash_value], str, MESSAGE_MAX_STRINGS_LENGTH); | 79 | strncpy(mString[hash_value], str, MESSAGE_MAX_STRINGS_LENGTH); /* Flawfinder: ignore */ |
80 | mString[hash_value][MESSAGE_MAX_STRINGS_LENGTH - 1] = 0; | 80 | mString[hash_value][MESSAGE_MAX_STRINGS_LENGTH - 1] = 0; |
81 | mEmpty[hash_value] = FALSE; | 81 | mEmpty[hash_value] = FALSE; |
82 | mUsed++; | 82 | mUsed++; |
diff --git a/linden/indra/llmessage/net.cpp b/linden/indra/llmessage/net.cpp index d21165e..de19ef8 100644 --- a/linden/indra/llmessage/net.cpp +++ b/linden/indra/llmessage/net.cpp | |||
@@ -143,7 +143,7 @@ char *u32_to_ip_string(U32 ip, char *ip_string) | |||
143 | if (result != NULL) | 143 | if (result != NULL) |
144 | { | 144 | { |
145 | //the function signature needs to change to pass in the lengfth of first and last. | 145 | //the function signature needs to change to pass in the lengfth of first and last. |
146 | strcpy(ip_string, result); | 146 | strcpy(ip_string, result); /*Flawfinder: ignore*/ |
147 | return ip_string; | 147 | return ip_string; |
148 | } | 148 | } |
149 | else | 149 | else |
diff --git a/linden/indra/llmessage/partsyspacket.cpp b/linden/indra/llmessage/partsyspacket.cpp index d491540..d6ba11e 100644 --- a/linden/indra/llmessage/partsyspacket.cpp +++ b/linden/indra/llmessage/partsyspacket.cpp | |||
@@ -1265,7 +1265,7 @@ BOOL LLPartSysCompressedPacket::fromUnsignedBytes(U8 *in, U32 bytesUsed) | |||
1265 | { | 1265 | { |
1266 | if ((in != NULL) && (bytesUsed <= sizeof(mData))) | 1266 | if ((in != NULL) && (bytesUsed <= sizeof(mData))) |
1267 | { | 1267 | { |
1268 | memcpy(mData, in, bytesUsed); | 1268 | memcpy(mData, in, bytesUsed); /* Flawfinder: ignore */ |
1269 | mNumBytes = bytesUsed; | 1269 | mNumBytes = bytesUsed; |
1270 | return TRUE; | 1270 | return TRUE; |
1271 | } | 1271 | } |