From cd17687f01420952712a500107e0f93e7ab8d5f8 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Fri, 15 Aug 2008 23:45:34 -0500 Subject: Second Life viewer sources 1.19.1.0 --- linden/indra/lscript/lscript_byteconvert.h | 37 +- linden/indra/lscript/lscript_compile/indra.l | 14 + .../lscript_compile/lscript_compile_fb_vc8.vcproj | 264 ++++---- .../lscript_compile/lscript_compile_fb_vc9.vcproj | 264 ++++---- .../lscript_compile/lscript_compile_ly_vc8.vcproj | 262 ++++---- .../lscript_compile/lscript_compile_vc8.vcproj | 662 ++++++++++---------- .../lscript_compile/lscript_compile_vc9.vcproj | 664 ++++++++++----------- .../lscript/lscript_execute/lscript_execute.cpp | 28 +- .../lscript_execute/lscript_execute_vc8.vcproj | 558 ++++++++--------- .../lscript_execute/lscript_execute_vc9.vcproj | 560 ++++++++--------- .../lscript/lscript_execute/lscript_readlso.cpp | 184 +++--- linden/indra/lscript/lscript_library.h | 8 +- .../lscript/lscript_library/lscript_alloc.cpp | 24 +- .../lscript/lscript_library/lscript_library.cpp | 12 +- .../lscript_library/lscript_library_vc8.vcproj | 542 ++++++++--------- .../lscript_library/lscript_library_vc9.vcproj | 544 ++++++++--------- 16 files changed, 2338 insertions(+), 2289 deletions(-) (limited to 'linden/indra/lscript') diff --git a/linden/indra/lscript/lscript_byteconvert.h b/linden/indra/lscript/lscript_byteconvert.h index 42f71e8..a9b0094 100644 --- a/linden/indra/lscript/lscript_byteconvert.h +++ b/linden/indra/lscript/lscript_byteconvert.h @@ -162,13 +162,19 @@ inline void bytestream_int2float(U8 *stream, S32 &offset) float2bytestream(stream, offset, fpvalue); } -inline void bytestream2char(char *buffer, const U8 *stream, S32 &offset) +// Returns true on success, return false and clip copy on buffer overflow +inline bool bytestream2char(char *buffer, const U8 *stream, S32 &offset, S32 buffsize) { - while ((*buffer++ = *(stream + offset++))) - ; + S32 source_len = strlen( (const char *)stream+offset ); + strncpy( buffer, (const char *)stream+offset, buffsize-1 ); + buffer[buffsize-1] = 0; + + offset += source_len + 1; // advance past source string, include terminating '\0' + + return source_len < buffsize; } -inline void char2bytestream(U8 *stream, S32 &offset, char *buffer) +inline void char2bytestream(U8 *stream, S32 &offset, const char *buffer) { while ((*(stream + offset++) = *buffer++)) ; @@ -1065,11 +1071,30 @@ inline void safe_instruction_float2bytestream(U8 *stream, S32 &offset, F32 value } } -inline void safe_instruction_bytestream2char(char *buffer, U8 *stream, S32 &offset) +inline void safe_instruction_bytestream2char(char *buffer, U8 *stream, S32 &offset, S32 buffsize) { - while ( (safe_instruction_check_address(stream, offset, 1)) + bool safe; + while ( (safe = safe_instruction_check_address(stream, offset, 1)) + && buffsize-- &&(*buffer++ = *(stream + offset++))) ; + + // Return if it ended in a null (success) or if script error handling is taking over + if( !safe || (0 == *(buffer-1)) ) + { + return; // Yep. Success. + } + + // Defensive mode. We copied at least one char and ran out of space before + // null termination. Add the terminator... + *(buffer-1) = 0; + + // ...and advance offset past the end of the data as if we copied the rest. If we + // violate the safety check, script error handling will protect us. No need to + // keep advancing. + while( safe_instruction_check_address(stream, offset, 1) + && *( stream + offset++ ) ) + ; } inline void safe_instruction_bytestream_count_char(U8 *stream, S32 &offset) diff --git a/linden/indra/lscript/lscript_compile/indra.l b/linden/indra/lscript/lscript_compile/indra.l index 57aef07..c8458a3 100644 --- a/linden/indra/lscript/lscript_compile/indra.l +++ b/linden/indra/lscript/lscript_compile/indra.l @@ -36,6 +36,7 @@ FS (f|F) #include "llparcelflags.h" #include "llregionflags.h" #include "lscript_http.h" +#include "llclickaction.h" void count(); void comment(); @@ -522,6 +523,10 @@ extern "C" { int yyerror(const char *fmt, ...); } "PARCEL_MEDIA_COMMAND_AGENT" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_AGENT; return(INTEGER_CONSTANT); } "PARCEL_MEDIA_COMMAND_UNLOAD" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_UNLOAD; return(INTEGER_CONSTANT); } "PARCEL_MEDIA_COMMAND_AUTO_ALIGN" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_AUTO_ALIGN; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_TYPE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_TYPE; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_SIZE" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_SIZE; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_DESC" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_DESC; return(INTEGER_CONSTANT); } +"PARCEL_MEDIA_COMMAND_LOOP_SET" { count(); yylval.ival = PARCEL_MEDIA_COMMAND_LOOP_SET; return(INTEGER_CONSTANT); } "LIST_STAT_MAX" { count(); yylval.ival = LIST_STAT_MAX; return(INTEGER_CONSTANT); } "LIST_STAT_MIN" { count(); yylval.ival = LIST_STAT_MIN; return(INTEGER_CONSTANT); } @@ -587,6 +592,15 @@ extern "C" { int yyerror(const char *fmt, ...); } "STRING_TRIM_TAIL" { count(); yylval.ival = STRING_TRIM_TAIL; return(INTEGER_CONSTANT); } "STRING_TRIM" { count(); yylval.ival = STRING_TRIM; return(INTEGER_CONSTANT); } +"CLICK_ACTION_NONE" { count(); yylval.ival = CLICK_ACTION_NONE; return(INTEGER_CONSTANT); } +"CLICK_ACTION_TOUCH" { count(); yylval.ival = CLICK_ACTION_TOUCH; return(INTEGER_CONSTANT); } +"CLICK_ACTION_SIT" { count(); yylval.ival = CLICK_ACTION_SIT; return(INTEGER_CONSTANT); } +"CLICK_ACTION_BUY" { count(); yylval.ival = CLICK_ACTION_BUY; return(INTEGER_CONSTANT); } +"CLICK_ACTION_PAY" { count(); yylval.ival = CLICK_ACTION_PAY; return(INTEGER_CONSTANT); } +"CLICK_ACTION_OPEN" { count(); yylval.ival = CLICK_ACTION_OPEN; return(INTEGER_CONSTANT); } +"CLICK_ACTION_PLAY" { count(); yylval.ival = CLICK_ACTION_PLAY; return(INTEGER_CONSTANT); } +"CLICK_ACTION_OPEN_MEDIA" { count(); yylval.ival = CLICK_ACTION_OPEN_MEDIA; return(INTEGER_CONSTANT); } + {L}({L}|{N})* { count(); yylval.sval = new char[strlen(yytext) + 1]; strcpy(yylval.sval, yytext); return(IDENTIFIER); } {N}+{E} { count(); yylval.fval = (F32)atof(yytext); return(FP_CONSTANT); } diff --git a/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc8.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc8.vcproj index 901a191..91561b9 100644 --- a/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc8.vcproj +++ b/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc8.vcproj @@ -1,133 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc9.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc9.vcproj index adfd694..62f3ada 100644 --- a/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc9.vcproj +++ b/linden/indra/lscript/lscript_compile/lscript_compile_fb_vc9.vcproj @@ -1,132 +1,132 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_compile/lscript_compile_ly_vc8.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile_ly_vc8.vcproj index baa202a..f55385e 100644 --- a/linden/indra/lscript/lscript_compile/lscript_compile_ly_vc8.vcproj +++ b/linden/indra/lscript/lscript_compile/lscript_compile_ly_vc8.vcproj @@ -1,131 +1,131 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_compile/lscript_compile_vc8.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile_vc8.vcproj index 919d290..0622c32 100644 --- a/linden/indra/lscript/lscript_compile/lscript_compile_vc8.vcproj +++ b/linden/indra/lscript/lscript_compile/lscript_compile_vc8.vcproj @@ -1,331 +1,331 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_compile/lscript_compile_vc9.vcproj b/linden/indra/lscript/lscript_compile/lscript_compile_vc9.vcproj index 4831422..581c99e 100644 --- a/linden/indra/lscript/lscript_compile/lscript_compile_vc9.vcproj +++ b/linden/indra/lscript/lscript_compile/lscript_compile_vc9.vcproj @@ -1,332 +1,332 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_execute/lscript_execute.cpp b/linden/indra/lscript/lscript_execute/lscript_execute.cpp index 1d2438c..d1200f0 100644 --- a/linden/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/linden/indra/lscript/lscript_execute/lscript_execute.cpp @@ -1333,7 +1333,7 @@ BOOL run_pushargs(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) S32 size = toffset - offset; char *arg = new char[size]; offset++; - safe_instruction_bytestream2char(arg, buffer, offset); + safe_instruction_bytestream2char(arg, buffer, offset, size); if (b_print) printf("%s\n", arg); S32 address = lsa_heap_add_data(buffer, new LLScriptLibData(arg), get_max_heap_size(buffer), TRUE); @@ -2753,7 +2753,7 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *sdata = new char[size]; - bytestream2char(sdata, buffer, string); + bytestream2char(sdata, buffer, string, size); if (strlen(sdata)) /*Flawfinder: ignore*/ { offset += arg; @@ -2781,7 +2781,7 @@ BOOL run_jumpif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *sdata = new char[size]; - bytestream2char(sdata, buffer, string); + bytestream2char(sdata, buffer, string, size); if (strlen(sdata)) /*Flawfinder: ignore*/ { LLUUID id; @@ -2880,7 +2880,7 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *sdata = new char[size]; - bytestream2char(sdata, buffer, string); + bytestream2char(sdata, buffer, string, size); if (!strlen(sdata)) /*Flawfinder: ignore*/ { offset += arg; @@ -2908,7 +2908,7 @@ BOOL run_jumpnif(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *sdata = new char[size]; - bytestream2char(sdata, buffer, string); + bytestream2char(sdata, buffer, string, size); if (strlen(sdata)) /*Flawfinder: ignore*/ { LLUUID id; @@ -3182,7 +3182,7 @@ BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *arg = new char[size]; - bytestream2char(arg, buffer, string); + bytestream2char(arg, buffer, string, size); // S32 length = strlen(arg); S32 dest; S32 base; @@ -3225,7 +3225,7 @@ BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *arg = new char[size]; - bytestream2char(arg, buffer, string); + bytestream2char(arg, buffer, string, size); F32 dest = (F32)atof(arg); @@ -3265,7 +3265,7 @@ BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *arg = new char[size]; - bytestream2char(arg, buffer, string); + bytestream2char(arg, buffer, string, size); LLVector3 vec; S32 num = sscanf(arg, "<%f, %f, %f>", &vec.mV[VX], &vec.mV[VY], &vec.mV[VZ]); if (num != 3) @@ -3295,7 +3295,7 @@ BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *arg = new char[size]; - bytestream2char(arg, buffer, string); + bytestream2char(arg, buffer, string, size); LLQuaternion quat; S32 num = sscanf(arg, "<%f, %f, %f, %f>", &quat.mQ[VX], &quat.mQ[VY], &quat.mQ[VZ], &quat.mQ[VW]); if (num != 4) @@ -3496,7 +3496,7 @@ void lscript_stacktol_pop_variable(LLScriptLibData *data, U8 *buffer, char type) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; data->mKey = new char[size]; - bytestream2char(data->mKey, buffer, string); + bytestream2char(data->mKey, buffer, string, size); } lsa_decrease_ref_count(buffer, base_address); } @@ -3523,7 +3523,7 @@ void lscript_stacktol_pop_variable(LLScriptLibData *data, U8 *buffer, char type) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; data->mString = new char[size]; - bytestream2char(data->mString, buffer, string); + bytestream2char(data->mString, buffer, string, size); } lsa_decrease_ref_count(buffer, base_address); } @@ -3623,7 +3623,7 @@ BOOL run_print(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; char *arg = new char[size]; - bytestream2char(arg, buffer, string); + bytestream2char(arg, buffer, string, size); printf("%s\n", arg); delete [] arg; } @@ -3787,7 +3787,7 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; data->mKey = new char[size]; - bytestream2char(data->mKey, buffer, string); + bytestream2char(data->mKey, buffer, string, size); } lsa_decrease_ref_count(buffer, base_address); } @@ -3814,7 +3814,7 @@ void lscript_pop_variable(LLScriptLibData *data, U8 *buffer, char type) safe_heap_bytestream_count_char(buffer, toffset); S32 size = toffset - string; data->mString = new char[size]; - bytestream2char(data->mString, buffer, string); + bytestream2char(data->mString, buffer, string, size); } lsa_decrease_ref_count(buffer, base_address); } diff --git a/linden/indra/lscript/lscript_execute/lscript_execute_vc8.vcproj b/linden/indra/lscript/lscript_execute/lscript_execute_vc8.vcproj index 2314e6a..8a1e4c6 100644 --- a/linden/indra/lscript/lscript_execute/lscript_execute_vc8.vcproj +++ b/linden/indra/lscript/lscript_execute/lscript_execute_vc8.vcproj @@ -1,279 +1,279 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_execute/lscript_execute_vc9.vcproj b/linden/indra/lscript/lscript_execute/lscript_execute_vc9.vcproj index 9c6f7e3..eb41122 100644 --- a/linden/indra/lscript/lscript_execute/lscript_execute_vc9.vcproj +++ b/linden/indra/lscript/lscript_execute/lscript_execute_vc9.vcproj @@ -1,280 +1,280 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_execute/lscript_readlso.cpp b/linden/indra/lscript/lscript_execute/lscript_readlso.cpp index b6d5092..218e14a 100644 --- a/linden/indra/lscript/lscript_execute/lscript_readlso.cpp +++ b/linden/indra/lscript/lscript_execute/lscript_readlso.cpp @@ -155,7 +155,7 @@ void LLScriptLSOParse::printGlobals(FILE *fp) type = *(mRawData + global_v_offset++); // set name - bytestream2char(name, mRawData, global_v_offset); + bytestream2char(name, mRawData, global_v_offset, sizeof(name)); switch(type) { @@ -261,7 +261,7 @@ void LLScriptLSOParse::printGlobalFunctions(FILE *fp) // where do the opcodes start opcode_start = bytestream2integer(mRawData, function_offset); opcode_start += orig_function_offset; - bytestream2char(name, mRawData, function_offset); + bytestream2char(name, mRawData, function_offset, sizeof(name)); // get return type type = *(mRawData + function_offset++); fprintf(fp, "[Function #%d] [0x%X] %s\n", function_number, orig_function_offset, name); @@ -272,7 +272,7 @@ void LLScriptLSOParse::printGlobalFunctions(FILE *fp) S32 pcount = 0; while (type) { - bytestream2char(name, mRawData, function_offset); + bytestream2char(name, mRawData, function_offset, sizeof(name)); fprintf(fp, "\tParameter #%d: %s %s\n", pcount++, LSCRIPTTypeNames[type], name); type = *(mRawData + function_offset++); } @@ -336,7 +336,7 @@ void LLScriptLSOParse::printStates(FILE *fp) state_info_offset += state_offset; fprintf(fp, "[0x%X] ", state_info_offset); state_info_offset += LSCRIPTDataSize[LST_INTEGER]; - bytestream2char(name, mRawData, state_info_offset); + bytestream2char(name, mRawData, state_info_offset, sizeof(name)); fprintf(fp, "%s\n", name); event_jump_table = state_info_offset; @@ -385,243 +385,243 @@ void LLScriptLSOParse::printStates(FILE *fp) switch(j) { case LSTT_STATE_ENTRY: // LSTT_STATE_ENTRY - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_STATE_EXIT: // LSTT_STATE_EXIT - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_TOUCH_START: // LSTT_TOUCH_START - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_TOUCH: // LSTT_TOUCH - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_TOUCH_END: // LSTT_TOUCH_END - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_COLLISION_START: // LSTT_COLLISION_START - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_COLLISION: // LSTT_COLLISION - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_COLLISION_END: // LSTT_COLLISION_END - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_LAND_COLLISION_START: // LSTT_LAND_COLLISION_START - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_LAND_COLLISION: // LSTT_LAND_COLLISION - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_LAND_COLLISION_END: // LSTT_LAND_COLLISION_END - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_INVENTORY: // LSTT_INVENTORY - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); break; case LSTT_ATTACH: // LSTT_ATTACH - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); break; case LSTT_DATASERVER: // LSTT_DATASERVER - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); break; case LSTT_TIMER: // LSTT_TIMER - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_MOVING_START: // LSTT_MOVING_START - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_MOVING_END: // LSTT_MOVING_END - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_CHAT: // LSTT_CHAT - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); break; case LSTT_OBJECT_REZ: // LSTT_OBJECT_REZ - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); break; case LSTT_REMOTE_DATA: // LSTT_REMOTE_DATA - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); break; case LSTT_REZ: // LSTT_REZ - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_SENSOR: // LSTT_SENSOR - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); break; case LSTT_NO_SENSOR: // LSTT_NO_SENSOR - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_CONTROL: // LSTT_CONTROL - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); break; case LSTT_LINK_MESSAGE: // LSTT_LINK_MESSAGE - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); break; case LSTT_MONEY: // LSTT_MONEY - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); break; case LSTT_EMAIL: // LSTT_EMAIL - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); break; case LSTT_AT_TARGET: // LSTT_AT_TARGET - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tvector %s\n", name); break; case LSTT_NOT_AT_TARGET: // LSTT_NOT_AT_TARGET - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_AT_ROT_TARGET: // LSTT_AT_ROT_TARGET - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tquaternion %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tquaternion %s\n", name); break; case LSTT_NOT_AT_ROT_TARGET: // LSTT_NOT_AT_TARGET - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); break; case LSTT_RTPERMISSIONS: // LSTT_RTPERMISSIONS - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); break; case LSTT_HTTP_RESPONSE: // LSTT_REMOTE_DATA ?!?!?! - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "%s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tkey %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tinteger %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tlist %s\n", name); - bytestream2char(name, mRawData, event_offset); + bytestream2char(name, mRawData, event_offset, sizeof(name)); fprintf(fp, "\t\tstring %s\n", name); break; default: @@ -1210,7 +1210,7 @@ void print_pushargs(FILE *fp, U8 *buffer, S32 &offset, S32 tabs) char arg[1024]; /*Flawfinder: ignore*/ lso_print_tabs(fp, tabs); fprintf(fp, "[0x%X]\tPUSHARGS ", offset++); - bytestream2char(arg, buffer, offset); + bytestream2char(arg, buffer, offset, sizeof(arg)); fprintf(fp, "%s\n", arg); } diff --git a/linden/indra/lscript/lscript_library.h b/linden/indra/lscript/lscript_library.h index 10ba7fa..458ab25 100644 --- a/linden/indra/lscript/lscript_library.h +++ b/linden/indra/lscript/lscript_library.h @@ -278,7 +278,7 @@ public: break; case LST_KEY: { - bytestream2char(temp, src, offset); + bytestream2char(temp, src, offset, sizeof(temp)); mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ if (mKey == NULL) { @@ -290,7 +290,7 @@ public: break; case LST_STRING: { - bytestream2char(temp, src, offset); + bytestream2char(temp, src, offset, sizeof(temp)); mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ if (mString == NULL) { @@ -327,7 +327,7 @@ public: break; case LST_KEY: { - bytestream2char(temp, src, offset); + bytestream2char(temp, src, offset, sizeof(temp)); mKey = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ if (mKey == NULL) { @@ -339,7 +339,7 @@ public: break; case LST_STRING: { - bytestream2char(temp, src, offset); + bytestream2char(temp, src, offset, sizeof(temp)); mString = new char[strlen(temp) + 1]; /* Flawfinder: ignore */ if (mString == NULL) { diff --git a/linden/indra/lscript/lscript_library/lscript_alloc.cpp b/linden/indra/lscript/lscript_library/lscript_alloc.cpp index a39edda..2c37d22 100644 --- a/linden/indra/lscript/lscript_library/lscript_alloc.cpp +++ b/linden/indra/lscript/lscript_library/lscript_alloc.cpp @@ -131,10 +131,12 @@ S32 lsa_heap_add_data(U8 *buffer, LLScriptLibData *data, S32 heapsize, BOOL b_de size = 4; break; case LST_KEY: - size = (S32)strlen(data->mKey) + 1; /*Flawfinder: ignore*/ + // NOTE: babbage: defensive as some library calls set data to NULL + size = data->mKey ? (S32)strlen(data->mKey) + 1 : 1; /*Flawfinder: ignore*/ break; case LST_STRING: - size = (S32)strlen(data->mString) + 1; /*Flawfinder: ignore*/ + // NOTE: babbage: defensive as some library calls set data to NULL + size = data->mString ? (S32)strlen(data->mString) + 1 : 1; /*Flawfinder: ignore*/ break; case LST_LIST: // list data 4 bytes of number of entries followed by number of pointer @@ -294,10 +296,10 @@ void lsa_insert_data(U8 *buffer, S32 &offset, LLScriptLibData *data, LLScriptAll float2bytestream(buffer, offset, data->mFP); break; case LST_KEY: - char2bytestream(buffer, offset, data->mKey); + char2bytestream(buffer, offset, data->mKey ? data->mKey : ""); break; case LST_STRING: - char2bytestream(buffer, offset, data->mString); + char2bytestream(buffer, offset, data->mString ? data->mString : ""); break; case LST_VECTOR: vector2bytestream(buffer, offset, data->mVec); @@ -524,7 +526,7 @@ void lsa_decrease_ref_count(U8 *buffer, S32 offset) alloc_entry2bytestream(buffer, orig_offset, entry); } -char gLSAStringRead[16384]; /*Flawfinder: ignore*/ +char gLSAStringRead[TOP_OF_MEMORY]; /*Flawfinder: ignore*/ LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) @@ -564,12 +566,12 @@ LLScriptLibData *lsa_get_data(U8 *buffer, S32 &offset, BOOL b_dec_ref) retval->mFP = bytestream2float(buffer, offset); break; case LST_KEY: - bytestream2char(gLSAStringRead, buffer, offset); + bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); // global sring buffer? for real? :( retval->mKey = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ strcpy(retval->mKey, gLSAStringRead); /*Flawfinder: ignore*/ break; case LST_STRING: - bytestream2char(gLSAStringRead, buffer, offset); + bytestream2char(gLSAStringRead, buffer, offset, sizeof(gLSAStringRead)); retval->mString = new char[strlen(gLSAStringRead) + 1]; /*Flawfinder: ignore*/ strcpy(retval->mString, gLSAStringRead); /*Flawfinder: ignore*/ break; @@ -816,11 +818,11 @@ void lsa_print_heap(U8 *buffer) printf("%f\n", fpvalue); break; case LST_STRING: - bytestream2char(string, buffer, readoffset); + bytestream2char(string, buffer, readoffset, sizeof(string)); printf("%s\n", string); break; case LST_KEY: - bytestream2char(string, buffer, readoffset); + bytestream2char(string, buffer, readoffset, sizeof(string)); printf("%s\n", string); break; case LST_VECTOR: @@ -883,11 +885,11 @@ void lsa_fprint_heap(U8 *buffer, FILE *fp) fprintf(fp, "%f\n", fpvalue); break; case LST_STRING: - bytestream2char(string, buffer, readoffset); + bytestream2char(string, buffer, readoffset, sizeof(string)); fprintf(fp, "%s\n", string); break; case LST_KEY: - bytestream2char(string, buffer, readoffset); + bytestream2char(string, buffer, readoffset, sizeof(string)); fprintf(fp, "%s\n", string); break; case LST_VECTOR: diff --git a/linden/indra/lscript/lscript_library/lscript_library.cpp b/linden/indra/lscript/lscript_library/lscript_library.cpp index 594a001..14019d0 100644 --- a/linden/indra/lscript/lscript_library/lscript_library.cpp +++ b/linden/indra/lscript/lscript_library/lscript_library.cpp @@ -29,7 +29,15 @@ * $/LicenseInfo$ */ -// *WARNING* + +// ## ## ### ######## ## ## #### ## ## ###### #### #### +// ## ## ## ## ## ## ## ### ## ## ### ## ## ## #### #### +// ## ## ## ## ## ## ## #### ## ## #### ## ## #### #### +// ## ## ## ## ## ######## ## ## ## ## ## ## ## ## #### ## ## +// ## ## ## ######### ## ## ## #### ## ## #### ## ## +// ## ## ## ## ## ## ## ## ### ## ## ### ## ## #### #### +// ### ### ## ## ## ## ## ## #### ## ## ###### #### #### +// // When adding functions, they MUST be appended to the end of // the init() method. The init() associates the name with a number, // which is then serialized into the bytecode. Inserting a new @@ -431,6 +439,8 @@ void LLScriptLibrary::init() addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llGetObjectDetails", "l", "kl", "list llGetObjectDetails(key id, list params)\nGets the object details specified in params for the object with key id.\nDetails are OBJECT_NAME, _DESC, _POS, _ROT, _VELOCITY, _OWNER, _GROUP, _CREATOR.")); + addFunction(new LLScriptLibraryFunction(10.f, 0.f, dummy_func, "llSetClickAction", NULL, "i", "llSetClickAction(integer action)\nSets the action performed when a prim is clicked upon.")); + // energy, sleep, dummy_func, name, return type, parameters, help text, gods-only // IF YOU ADD NEW SCRIPT CALLS, YOU MUST PUT THEM AT THE END OF THIS LIST. diff --git a/linden/indra/lscript/lscript_library/lscript_library_vc8.vcproj b/linden/indra/lscript/lscript_library/lscript_library_vc8.vcproj index 371f880..38a951b 100644 --- a/linden/indra/lscript/lscript_library/lscript_library_vc8.vcproj +++ b/linden/indra/lscript/lscript_library/lscript_library_vc8.vcproj @@ -1,271 +1,271 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/lscript/lscript_library/lscript_library_vc9.vcproj b/linden/indra/lscript/lscript_library/lscript_library_vc9.vcproj index 031b67d..63ffbac 100644 --- a/linden/indra/lscript/lscript_library/lscript_library_vc9.vcproj +++ b/linden/indra/lscript/lscript_library/lscript_library_vc9.vcproj @@ -1,272 +1,272 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.1