summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorAnnieRuru <jeankof@ymail.com>2015-11-16 01:04:55 +0800
committerHaru <haru@dotalux.com>2015-12-22 04:11:51 +0100
commitfeff016d6bc7e811d03c958da754df20f630b33b (patch)
treee16b5eb79113536d37a54fa2ceb3f6236472d053 /src/map/script.c
parentc276e2a6aa566400b1026236e7b2c09bfdcb72b5 (diff)
downloadhercules-feff016d6bc7e811d03c958da754df20f630b33b.tar.gz
hercules-feff016d6bc7e811d03c958da754df20f630b33b.tar.bz2
hercules-feff016d6bc7e811d03c958da754df20f630b33b.tar.xz
hercules-feff016d6bc7e811d03c958da754df20f630b33b.zip
Throw error when variable name length too long
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c14
1 files changed, 14 insertions, 0 deletions
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;