diff options
-rw-r--r-- | doc/script_commands.txt | 3 | ||||
-rw-r--r-- | src/map/script.c | 14 |
2 files changed, 16 insertions, 1 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index ef4816889..c08596f9a 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -525,7 +525,8 @@ If a variable was never set, it is considered to equal zero for integer variables or an empty string ("", nothing between the quotes) for string variables. Once you set it to that, the variable is as good as forgotten forever, and no trace remains of it even if it was stored with character -or account data. +or account data. The maximum length of variable name including prefix and +suffix is 32. Some variables are special, that is, they are already defined for you by the scripting engine. You can see the full list somewhere in diff --git a/src/map/script.c b/src/map/script.c index 7a5292159..829555820 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -2726,6 +2726,13 @@ struct script_data *get_val(struct script_state* st, struct script_data* data) { prefix = name[0]; postfix = name[strlen(name) - 1]; + if (strlen(name) > SCRIPT_VARNAME_LENGTH) { + ShowError("script_get_val: variable name too long. '%s'\n", name); + script->reportsrc(st); + st->state = END; + return data; + } + //##TODO use reference_tovariable(data) when it's confirmed that it works [FlavioJS] if( !reference_toconstant(data) && not_server_variable(prefix) ) { sd = script->rid2sd(st); @@ -3142,6 +3149,13 @@ void set_reg_instance_num(struct script_state* st, int64 num, const char* name, int set_reg(struct script_state* st, TBL_PC* sd, int64 num, const char* name, const void* value, struct reg_db *ref) { char prefix = name[0]; + if (strlen(name) > SCRIPT_VARNAME_LENGTH) { + ShowError("script:set_reg: variable name too long. '%s'\n", name); + script->reportsrc(st); + st->state = END; + return 0; + } + if( is_string_variable(name) ) {// string variable const char *str = (const char*)value; |