diff options
author | Haru <haru@dotalux.com> | 2020-05-10 20:35:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-10 20:35:59 +0200 |
commit | 0d66a7243aa6e129cddea4ca09c2616354c23ffa (patch) | |
tree | 56fe416e50f56c2265d72b920efd238538ac22ab /src/map/intif.c | |
parent | 944d8489f1bcca93e6b2ff06a159084f064dce12 (diff) | |
parent | 66f9a2a1bc2fd509d13729ad6bc586a3b7ad2347 (diff) | |
download | hercules-0d66a7243aa6e129cddea4ca09c2616354c23ffa.tar.gz hercules-0d66a7243aa6e129cddea4ca09c2616354c23ffa.tar.bz2 hercules-0d66a7243aa6e129cddea4ca09c2616354c23ffa.tar.xz hercules-0d66a7243aa6e129cddea4ca09c2616354c23ffa.zip |
Merge pull request #2705 from Kenpachi2k13/string_var_size
Cap string variable value length and unify corresponding SQL columns size
Diffstat (limited to 'src/map/intif.c')
-rw-r--r-- | src/map/intif.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/map/intif.c b/src/map/intif.c index a420b7204..276b40780 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -218,13 +218,13 @@ static int intif_saveregistry(struct map_session_data *sd) plen += 1; if( p->value ) { - len = strlen(p->value)+1; + len = strlen(p->value); - WFIFOB(inter_fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */ + WFIFOB(inter_fd, plen) = (unsigned char)len; // Won't be higher; the column size is 255. plen += 1; - safestrncpy(WFIFOP(inter_fd,plen), p->value, len); - plen += len; + safestrncpy(WFIFOP(inter_fd, plen), p->value, len + 1); + plen += len + 1; } else { script->reg_destroy_single(sd,key.i64,&p->flag); } @@ -1025,7 +1025,7 @@ static void intif_parse_Registers(int fd) * { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) } **/ if (type) { - char sval[254]; + char sval[SCRIPT_STRING_VAR_LENGTH + 1]; for (i = 0; i < max; i++) { int len = RFIFOB(fd, cursor); safestrncpy(key, RFIFOP(fd, cursor + 1), min((int)sizeof(key), len)); @@ -1035,8 +1035,8 @@ static void intif_parse_Registers(int fd) cursor += 4; len = RFIFOB(fd, cursor); - safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len)); - cursor += len + 1; + safestrncpy(sval, RFIFOP(fd, cursor + 1), min((int)sizeof(sval), len + 1)); + cursor += len + 2; script->set_reg(NULL,sd,reference_uid(script->add_variable(key), index), key, sval, NULL); } |