diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/lscript/lscript_byteconvert.h | 41 | ||||
-rw-r--r-- | linden/indra/lscript/lscript_compile/indra.l | 1 |
2 files changed, 21 insertions, 21 deletions
diff --git a/linden/indra/lscript/lscript_byteconvert.h b/linden/indra/lscript/lscript_byteconvert.h index a9b0094..e17f3fc 100644 --- a/linden/indra/lscript/lscript_byteconvert.h +++ b/linden/indra/lscript/lscript_byteconvert.h | |||
@@ -166,8 +166,15 @@ inline void bytestream_int2float(U8 *stream, S32 &offset) | |||
166 | inline bool bytestream2char(char *buffer, const U8 *stream, S32 &offset, S32 buffsize) | 166 | inline bool bytestream2char(char *buffer, const U8 *stream, S32 &offset, S32 buffsize) |
167 | { | 167 | { |
168 | S32 source_len = strlen( (const char *)stream+offset ); | 168 | S32 source_len = strlen( (const char *)stream+offset ); |
169 | strncpy( buffer, (const char *)stream+offset, buffsize-1 ); | 169 | S32 copy_len = buffsize - 1; |
170 | buffer[buffsize-1] = 0; | 170 | if( copy_len > source_len ) |
171 | { | ||
172 | copy_len = source_len; | ||
173 | } | ||
174 | |||
175 | // strncpy without \0 padding overhead | ||
176 | memcpy( buffer, stream+offset, copy_len ); | ||
177 | buffer[copy_len] = 0; | ||
171 | 178 | ||
172 | offset += source_len + 1; // advance past source string, include terminating '\0' | 179 | offset += source_len + 1; // advance past source string, include terminating '\0' |
173 | 180 | ||
@@ -1073,28 +1080,20 @@ inline void safe_instruction_float2bytestream(U8 *stream, S32 &offset, F32 value | |||
1073 | 1080 | ||
1074 | inline void safe_instruction_bytestream2char(char *buffer, U8 *stream, S32 &offset, S32 buffsize) | 1081 | inline void safe_instruction_bytestream2char(char *buffer, U8 *stream, S32 &offset, S32 buffsize) |
1075 | { | 1082 | { |
1076 | bool safe; | 1083 | // This varies from the old method. Previously, we would copy up until we got an error, |
1077 | while ( (safe = safe_instruction_check_address(stream, offset, 1)) | 1084 | // then halt the script via safe_isntruction_check_address. Now we don't bother |
1078 | && buffsize-- | 1085 | // copying a thing if there's an error. |
1079 | &&(*buffer++ = *(stream + offset++))) | ||
1080 | ; | ||
1081 | 1086 | ||
1082 | // Return if it ended in a null (success) or if script error handling is taking over | 1087 | if( safe_instruction_check_address(stream, offset, strlen( (const char *)stream + offset ) + 1 ) ) |
1083 | if( !safe || (0 == *(buffer-1)) ) | ||
1084 | { | 1088 | { |
1085 | return; // Yep. Success. | 1089 | // Takes the same parms as this function. Won't overread, per above check. |
1090 | bytestream2char( buffer, stream, offset, buffsize ); | ||
1091 | } | ||
1092 | else | ||
1093 | { | ||
1094 | // Truncate - no point in copying | ||
1095 | *buffer = 0; | ||
1086 | } | 1096 | } |
1087 | |||
1088 | // Defensive mode. We copied at least one char and ran out of space before | ||
1089 | // null termination. Add the terminator... | ||
1090 | *(buffer-1) = 0; | ||
1091 | |||
1092 | // ...and advance offset past the end of the data as if we copied the rest. If we | ||
1093 | // violate the safety check, script error handling will protect us. No need to | ||
1094 | // keep advancing. | ||
1095 | while( safe_instruction_check_address(stream, offset, 1) | ||
1096 | && *( stream + offset++ ) ) | ||
1097 | ; | ||
1098 | } | 1097 | } |
1099 | 1098 | ||
1100 | inline void safe_instruction_bytestream_count_char(U8 *stream, S32 &offset) | 1099 | 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 c8458a3..8bb26ab 100644 --- a/linden/indra/lscript/lscript_compile/indra.l +++ b/linden/indra/lscript/lscript_compile/indra.l | |||
@@ -445,6 +445,7 @@ extern "C" { int yyerror(const char *fmt, ...); } | |||
445 | "PRIM_BUMP_SHINY" { count(); yylval.ival = LSL_PRIM_BUMP_SHINY; return(INTEGER_CONSTANT); } | 445 | "PRIM_BUMP_SHINY" { count(); yylval.ival = LSL_PRIM_BUMP_SHINY; return(INTEGER_CONSTANT); } |
446 | "PRIM_FULLBRIGHT" { count(); yylval.ival = LSL_PRIM_FULLBRIGHT; return(INTEGER_CONSTANT); } | 446 | "PRIM_FULLBRIGHT" { count(); yylval.ival = LSL_PRIM_FULLBRIGHT; return(INTEGER_CONSTANT); } |
447 | "PRIM_TEXGEN" { count(); yylval.ival = LSL_PRIM_TEXGEN; return(INTEGER_CONSTANT); } | 447 | "PRIM_TEXGEN" { count(); yylval.ival = LSL_PRIM_TEXGEN; return(INTEGER_CONSTANT); } |
448 | "PRIM_GLOW" { count(); yylval.ival = LSL_PRIM_GLOW; return(INTEGER_CONSTANT); } | ||
448 | 449 | ||
449 | "PRIM_TYPE_BOX" { count(); yylval.ival = LSL_PRIM_TYPE_BOX; return(INTEGER_CONSTANT); } | 450 | "PRIM_TYPE_BOX" { count(); yylval.ival = LSL_PRIM_TYPE_BOX; return(INTEGER_CONSTANT); } |
450 | "PRIM_TYPE_CYLINDER" { count(); yylval.ival = LSL_PRIM_TYPE_CYLINDER; return(INTEGER_CONSTANT); } | 451 | "PRIM_TYPE_CYLINDER" { count(); yylval.ival = LSL_PRIM_TYPE_CYLINDER; return(INTEGER_CONSTANT); } |