summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-09 20:48:23 +0200
committerKenpachi Developer <Kenpachi.Developer@gmx.de>2020-05-09 20:48:23 +0200
commit66de70164a1cd0fed59671e09bad7c2fca1d90eb (patch)
tree59dd96e7af743736bf96899346c01e1d56895ae3
parent8226a31d9c46950df20afaad08c2f22745f74088 (diff)
downloadhercules-66de70164a1cd0fed59671e09bad7c2fca1d90eb.tar.gz
hercules-66de70164a1cd0fed59671e09bad7c2fca1d90eb.tar.bz2
hercules-66de70164a1cd0fed59671e09bad7c2fca1d90eb.tar.xz
hercules-66de70164a1cd0fed59671e09bad7c2fca1d90eb.zip
Validate length of value for permanent string variables in set_reg() function
-rw-r--r--src/map/script.c12
1 files changed, 12 insertions, 0 deletions
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) {