diff options
Diffstat (limited to 'indra/llmessage/message.cpp')
-rw-r--r-- | indra/llmessage/message.cpp | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/indra/llmessage/message.cpp b/indra/llmessage/message.cpp index f849e989b4..dc05e9c8ed 100644 --- a/indra/llmessage/message.cpp +++ b/indra/llmessage/message.cpp @@ -968,7 +968,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) LLMessageVariable var; char var_name[MAX_MESSAGE_INTERNAL_NAME_SIZE]; /* Flawfinder: ignore */ - char formatString[MAX_MESSAGE_INTERNAL_NAME_SIZE]; + char formatString[MAX_MESSAGE_INTERNAL_NAME_SIZE]; /* Flawfinder: ignore */ FILE* messagefilep = NULL; mMessageFileChecksum = 0; @@ -976,14 +976,19 @@ void LLMessageSystem::loadTemplateFile(const char* filename) S32 checksum_offset = 0; char* checkp = NULL; - snprintf(formatString, sizeof(formatString), "%%%ds", MAX_MESSAGE_INTERNAL_NAME_SIZE); - messagefilep = LLFile::fopen(filename, "r"); + // scanf needs 1 byte more than width, thus the MAX_... -1. + snprintf( /* Flawfinder: ignore */ + formatString, + sizeof(formatString), + "%%%ds", + MAX_MESSAGE_INTERNAL_NAME_SIZE - 1); + messagefilep = LLFile::fopen(filename, "r"); /* Flawfinder: ignore */ if (messagefilep) { // mName = gMessageStringTable.getString(filename); fseek(messagefilep, 0L, SEEK_SET ); - while(fscanf(messagefilep, formatString, token) != EOF) + while(fscanf(messagefilep, formatString, token) != EOF) /* Flawfinder: ignore */ { // skip comments if (token[0] == '/') @@ -1113,7 +1118,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) b_template = FALSE; // name first - if (fscanf(messagefilep, formatString, template_name) == EOF) + if (fscanf(messagefilep, formatString, template_name) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected message template name, but file ended" @@ -1145,7 +1150,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) } // ok, now get Frequency ("High", "Medium", or "Low") - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected message template frequency, found EOF." @@ -1226,7 +1231,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) else if (!strcmp(token, "Fixed")) { U32 message_num = 0; - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected message template number (fixed)," @@ -1260,7 +1265,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) } // Now get trust ("Trusted", "NotTrusted") - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // File ended llerrs << "Expected message template " @@ -1297,7 +1302,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) } // get encoding - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // File ended llerrs << "Expected message encoding, but file ended." @@ -1343,7 +1348,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) // ok, need to pull header info // name first - if (fscanf(messagefilep, formatString, block_name) == EOF) + if (fscanf(messagefilep, formatString, block_name) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected block name, but file ended" << llendl; @@ -1371,7 +1376,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) } // now, block type ("Single", "Multiple", or "Variable") - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected block type, but file ended." << llendl; @@ -1396,7 +1401,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) else if (!strcmp(token, "Multiple")) { // need to get the number of repeats - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected block multiple count," @@ -1452,7 +1457,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) // ok, need to pull header info // name first - if (fscanf(messagefilep, formatString, var_name) == EOF) + if (fscanf(messagefilep, formatString, var_name) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected variable name, but file ended." @@ -1481,7 +1486,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) } // now, variable type ("Fixed" or "Variable") - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected variable type, but file ended" @@ -1575,7 +1580,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) else if (!strcmp(token, "Fixed")) { // need to get the variable size - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected variable size, but file ended" @@ -1608,7 +1613,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) else if (!strcmp(token, "Variable")) { // need to get the variable size - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected variable size, but file ended" @@ -1657,7 +1662,7 @@ void LLMessageSystem::loadTemplateFile(const char* filename) if (!strcmp(token, "version")) { // version number - if (fscanf(messagefilep, formatString, token) == EOF) + if (fscanf(messagefilep, formatString, token) == EOF) /* Flawfinder: ignore */ { // oops, file ended llerrs << "Expected version number, but file ended" @@ -2715,7 +2720,7 @@ void LLMessageSystem::buildMessage() temp_block_number = (U8)mbci->mBlockNumber; if ((S32)(mSendSize + sizeof(U8)) < MAX_BUFFER_SIZE) { - memcpy(&mSendBuffer[mSendSize], &temp_block_number, sizeof(U8)); + memcpy(&mSendBuffer[mSendSize], &temp_block_number, sizeof(U8)); /* Flawfinder: ignore */ mSendSize += sizeof(U8); } else @@ -2792,7 +2797,7 @@ void LLMessageSystem::buildMessage() { if(mSendSize + mvci.getSize() < (S32)sizeof(mSendBuffer)) { - memcpy( + memcpy( /* Flawfinder: ignore */ &mSendBuffer[mSendSize], mvci.getData(), mvci.getSize()); @@ -3058,7 +3063,7 @@ S32 LLMessageSystem::sendMessage(const LLHost &host) if((S32)(buffer_length + sizeof(TPACKETID)) < MAX_BUFFER_SIZE) { - memcpy(&buf_ptr[buffer_length], &packet_id, sizeof(TPACKETID)); + memcpy(&buf_ptr[buffer_length], &packet_id, sizeof(TPACKETID)); /* Flawfinder: ignore */ // Do the accounting buffer_length += sizeof(TPACKETID); } @@ -3166,7 +3171,7 @@ BOOL LLMessageSystem::decodeTemplate( // it appears that if there is a NULL in the message #, it won't copy it.... // what was the goal? //if(header[2]) - memcpy(&message_id_U16, &header[2], 2); + memcpy(&message_id_U16, &header[2], 2); /* Flawfinder: ignore */ // dependant on endian-ness: // U32 temp = (255 << 24) | (255 << 16) | header[2]; @@ -3577,7 +3582,7 @@ void LLMessageSystem::getDataFast(const char *blockname, const char *varname, vo ((U32*)datap)[1] = ((U32*)vardata.getData())[1]; break; default: - memcpy(datap, vardata.getData(), vardata_size); + memcpy(datap, vardata.getData(), vardata_size); /* Flawfinder: ignore */ break; } } @@ -3589,7 +3594,7 @@ void LLMessageSystem::getDataFast(const char *blockname, const char *varname, vo << " but truncated to max size of " << max_size << llendl; - memcpy(datap, vardata.getData(), max_size); + memcpy(datap, vardata.getData(), max_size); /* Flawfinder: ignore */ } } @@ -4456,7 +4461,7 @@ void process_create_trusted_circuit(LLMessageSystem *msg, void **) return; } - char their_digest[MD5HEX_STR_SIZE]; + char their_digest[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ S32 size = msg->getSizeFast(_PREHASH_DataBlock, _PREHASH_Digest); if(size != MD5HEX_STR_BYTES) { @@ -4536,7 +4541,7 @@ void encrypt_template(const char *src_name, const char *dest_name) BOOL decrypt_template(const char *src_name, const char *dest_name) { S32 buf_length = LL_ENCRYPT_BUF_LENGTH; - char buf[LL_ENCRYPT_BUF_LENGTH]; + char buf[LL_ENCRYPT_BUF_LENGTH]; /* Flawfinder: ignore */ FILE* infp = NULL; FILE* outfp = NULL; @@ -4551,7 +4556,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) goto exit; } - infp = LLFile::fopen(src_name,"rb"); + infp = LLFile::fopen(src_name,"rb"); /* Flawfinder: ignore */ if (!infp) { llwarns << "could not open " << src_name << " for reading" << llendl; @@ -4564,7 +4569,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) goto exit; } - outfp = LLFile::fopen(dest_name,"w+b"); + outfp = LLFile::fopen(dest_name,"w+b"); /* Flawfinder: ignore */ if (!outfp) { llwarns << "could not open " << src_name << " for writing" << llendl; @@ -4599,7 +4604,7 @@ BOOL decrypt_template(const char *src_name, const char *dest_name) void dump_prehash_files() { U32 i; - FILE *fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); + FILE* fp = LLFile::fopen("../../indra/llmessage/message_prehash.h", "w"); /* Flawfinder: ignore */ if (fp) { fprintf( @@ -4631,7 +4636,7 @@ void dump_prehash_files() fprintf(fp, "\n\n#endif\n"); fclose(fp); } - fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); + fp = LLFile::fopen("../../indra/llmessage/message_prehash.cpp", "w"); /* Flawfinder: ignore */ if (fp) { fprintf( @@ -5562,7 +5567,7 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 nu if( secret != NULL) { - d.update(secret, (U32)strlen((char *) secret)); + d.update(secret, (U32)strlen((char *) secret)); /* Flawfinder: ignore */ } d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ @@ -5573,13 +5578,13 @@ bool LLMessageSystem::generateDigestForNumberAndUUIDs(char* digest, const U32 nu d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ if( (char*) id1str != NULL) { - d.update(id1str, (U32)strlen((char *) id1str)); + d.update(id1str, (U32)strlen((char *) id1str)); /* Flawfinder: ignore */ } d.update((const unsigned char *) colon, (U32)strlen(colon)); /* Flawfinder: ignore */ if( (char*) id2str != NULL) { - d.update(id2str, (U32)strlen((char *) id2str)); + d.update(id2str, (U32)strlen((char *) id2str)); /* Flawfinder: ignore */ } d.finalize(); |