From 66de70164a1cd0fed59671e09bad7c2fca1d90eb Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Sat, 9 May 2020 20:48:23 +0200 Subject: Validate length of value for permanent string variables in set_reg() function --- src/map/script.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/map/script.c b/src/map/script.c index e5c407cc7..8204e5187 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -3465,6 +3465,18 @@ static int set_reg(struct script_state *st, struct map_session_data *sd, int64 n if (is_string_variable(name)) {// string variable const char *str = (const char*)value; + if (script->is_permanent_variable(name) && strlen(str) > SCRIPT_STRING_VAR_LENGTH) { + ShowError("script:set_reg: Value of variable %s is too long: %lu! Maximum is %d. Skipping...\n", + name, strlen(str), SCRIPT_STRING_VAR_LENGTH); + + if (st != NULL) { + script->reportsrc(st); + st->state = END; + } + + return 0; + } + switch (prefix) { case '@': if (ref) { -- cgit v1.2.3-70-g09d2