diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/lscript/lscript_execute/lscript_execute.cpp | 49 |
1 files changed, 11 insertions, 38 deletions
diff --git a/linden/indra/lscript/lscript_execute/lscript_execute.cpp b/linden/indra/lscript/lscript_execute/lscript_execute.cpp index d1200f0..643f3f6 100644 --- a/linden/indra/lscript/lscript_execute/lscript_execute.cpp +++ b/linden/indra/lscript/lscript_execute/lscript_execute.cpp | |||
@@ -61,7 +61,7 @@ char* LSCRIPTRunTimeFaultStrings[LSRF_EOF] = /*Flawfinder: ignore*/ | |||
61 | //static | 61 | //static |
62 | S64 LLScriptExecute::sGlobalInstructionCount = 0; | 62 | S64 LLScriptExecute::sGlobalInstructionCount = 0; |
63 | 63 | ||
64 | LLScriptExecute::LLScriptExecute(FILE *fp) | 64 | LLScriptExecute::LLScriptExecute(LLFILE *fp) |
65 | { | 65 | { |
66 | U8 sizearray[4]; | 66 | U8 sizearray[4]; |
67 | S32 filesize; | 67 | S32 filesize; |
@@ -3027,46 +3027,19 @@ BOOL run_return(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) | |||
3027 | if (b_print) | 3027 | if (b_print) |
3028 | printf("[0x%X]\tRETURN\n", offset); | 3028 | printf("[0x%X]\tRETURN\n", offset); |
3029 | offset++; | 3029 | offset++; |
3030 | S32 bp = lscript_pop_int(buffer); | 3030 | |
3031 | // SEC-53: babbage: broken instructions may allow inbalanced pushes and | ||
3032 | // pops which can cause caller BP and return IP to be corrupted, so restore | ||
3033 | // SP from BP before popping caller BP and IP. | ||
3034 | S32 bp = get_register(buffer, LREG_BP); | ||
3035 | set_sp(buffer, bp); | ||
3036 | |||
3037 | bp = lscript_pop_int(buffer); | ||
3031 | set_bp(buffer, bp); | 3038 | set_bp(buffer, bp); |
3032 | offset = lscript_pop_int(buffer); | 3039 | offset = lscript_pop_int(buffer); |
3033 | return FALSE; | 3040 | return FALSE; |
3034 | } | 3041 | } |
3035 | 3042 | ||
3036 | S32 axtoi(char *hexStg) | ||
3037 | { | ||
3038 | S32 n = 0; // position in string | ||
3039 | S32 m = 0; // position in digit[] to shift | ||
3040 | S32 count; // loop index | ||
3041 | S32 intValue = 0; // integer value of hex string | ||
3042 | S32 digit[9]; // hold values to convert | ||
3043 | while (n < 8) | ||
3044 | { | ||
3045 | if (hexStg[n]=='\0') | ||
3046 | break; | ||
3047 | if (hexStg[n] > 0x29 && hexStg[n] < 0x40 ) //if 0 to 9 | ||
3048 | digit[n] = hexStg[n] & 0x0f; //convert to int | ||
3049 | else if (hexStg[n] >='a' && hexStg[n] <= 'f') //if a to f | ||
3050 | digit[n] = (hexStg[n] & 0x0f) + 9; //convert to int | ||
3051 | else if (hexStg[n] >='A' && hexStg[n] <= 'F') //if A to F | ||
3052 | digit[n] = (hexStg[n] & 0x0f) + 9; //convert to int | ||
3053 | else break; | ||
3054 | n++; | ||
3055 | } | ||
3056 | count = n; | ||
3057 | m = n - 1; | ||
3058 | n = 0; | ||
3059 | while(n < count) | ||
3060 | { | ||
3061 | // digit[n] is value of hex digit at position n | ||
3062 | // (m << 2) is the number of positions to shift | ||
3063 | // OR the bits into return value | ||
3064 | intValue = intValue | (digit[n] << (m << 2)); | ||
3065 | m--; // adjust the position to set | ||
3066 | n++; // next digit to process | ||
3067 | } | ||
3068 | return (intValue); | ||
3069 | } | ||
3070 | 3043 | ||
3071 | 3044 | ||
3072 | BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) | 3045 | BOOL run_cast(U8 *buffer, S32 &offset, BOOL b_print, const LLUUID &id) |
@@ -3718,7 +3691,7 @@ void lscript_run(char *filename, BOOL b_debug) | |||
3718 | BOOL b_state; | 3691 | BOOL b_state; |
3719 | LLScriptExecute *execute = NULL; | 3692 | LLScriptExecute *execute = NULL; |
3720 | 3693 | ||
3721 | FILE* file = LLFile::fopen(filename, "r"); | 3694 | LLFILE* file = LLFile::fopen(filename, "r"); |
3722 | if (file) | 3695 | if (file) |
3723 | { | 3696 | { |
3724 | execute = new LLScriptExecute(file); | 3697 | execute = new LLScriptExecute(file); |
@@ -3727,7 +3700,7 @@ void lscript_run(char *filename, BOOL b_debug) | |||
3727 | file = LLFile::fopen(filename, "r"); | 3700 | file = LLFile::fopen(filename, "r"); |
3728 | if (file) | 3701 | if (file) |
3729 | { | 3702 | { |
3730 | FILE* fp = LLFile::fopen("lscript.parse", "w"); /*Flawfinder: ignore*/ | 3703 | LLFILE* fp = LLFile::fopen("lscript.parse", "w"); /*Flawfinder: ignore*/ |
3731 | LLScriptLSOParse *parse = new LLScriptLSOParse(file); | 3704 | LLScriptLSOParse *parse = new LLScriptLSOParse(file); |
3732 | parse->printData(fp); | 3705 | parse->printData(fp); |
3733 | delete parse; | 3706 | delete parse; |