diff options
author | Haru <haru@dotalux.com> | 2016-04-30 00:11:44 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-04-30 00:11:44 +0200 |
commit | e88ac41acf8d488c2b96771372a34880069e251a (patch) | |
tree | bed4fa20c35bd180498c23586f20883f57b7cba6 /src | |
parent | 8ac699f4840bdadfb92326250295e1fed8286183 (diff) | |
download | hercules-e88ac41acf8d488c2b96771372a34880069e251a.tar.gz hercules-e88ac41acf8d488c2b96771372a34880069e251a.tar.bz2 hercules-e88ac41acf8d488c2b96771372a34880069e251a.tar.xz hercules-e88ac41acf8d488c2b96771372a34880069e251a.zip |
Corrected truncation of the last letter in whisper messages
- Follow-up to ccfd054
- Fixes #1275
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/char/inter.c | 6 | ||||
-rw-r--r-- | src/map/clif.c | 14 | ||||
-rw-r--r-- | src/map/intif.c | 6 | ||||
-rw-r--r-- | src/map/pc.c | 2 |
4 files changed, 14 insertions, 14 deletions
diff --git a/src/char/inter.c b/src/char/inter.c index 9fea2885c..8f7f5c144 100644 --- a/src/char/inter.c +++ b/src/char/inter.c @@ -968,8 +968,8 @@ int mapif_wis_message(struct WisData *wd) //if (wd->len > 2047-56) wd->len = 2047-56; //Force it to fit to avoid crashes. [Skotlex] if (wd->len < 0) wd->len = 0; - if (wd->len >= sizeof(wd->msg) - 1) - wd->len = sizeof(wd->msg) - 1; + if (wd->len >= (int)sizeof(wd->msg) - 1) + wd->len = (int)sizeof(wd->msg) - 1; WBUFW(buf, 0) = 0x3801; WBUFW(buf, 2) = 56 +wd->len; @@ -1172,7 +1172,7 @@ int mapif_parse_WisToGM(int fd) { unsigned char buf[2048]; // 0x3003/0x3803 <packet_len>.w <wispname>.24B <min_gm_level>.w <message>.?B - memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2)); + memcpy(WBUFP(buf,0), RFIFOP(fd,0), RFIFOW(fd,2)); // Message contains the NUL terminator (see intif_wis_message_to_gm()) WBUFW(buf, 0) = 0x3803; mapif->sendall(buf, RFIFOW(fd,2)); diff --git a/src/map/clif.c b/src/map/clif.c index 1948eecea..96e458600 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -5814,21 +5814,21 @@ void clif_wis_message(int fd, const char *nick, const char *mes, int mes_len) nullpo_retv(mes); #if PACKETVER < 20091104 - WFIFOHEAD(fd, mes_len + NAME_LENGTH + 4); + WFIFOHEAD(fd, mes_len + NAME_LENGTH + 5); WFIFOW(fd,0) = 0x97; - WFIFOW(fd,2) = mes_len + NAME_LENGTH + 4; + WFIFOW(fd,2) = mes_len + NAME_LENGTH + 5; safestrncpy(WFIFOP(fd,4), nick, NAME_LENGTH); - safestrncpy(WFIFOP(fd,28), mes, mes_len); + safestrncpy(WFIFOP(fd,28), mes, mes_len + 1); WFIFOSET(fd,WFIFOW(fd,2)); #else ssd = map->nick2sd(nick); - WFIFOHEAD(fd, mes_len + NAME_LENGTH + 8); + WFIFOHEAD(fd, mes_len + NAME_LENGTH + 9); WFIFOW(fd,0) = 0x97; - WFIFOW(fd,2) = mes_len + NAME_LENGTH + 8; + WFIFOW(fd,2) = mes_len + NAME_LENGTH + 9; safestrncpy(WFIFOP(fd,4), nick, NAME_LENGTH); WFIFOL(fd,28) = (ssd && pc_get_group_level(ssd) == 99) ? 1 : 0; // isAdmin; if nonzero, also displays text above char - safestrncpy(WFIFOP(fd,32), mes, mes_len); + safestrncpy(WFIFOP(fd,32), mes, mes_len + 1); WFIFOSET(fd,WFIFOW(fd,2)); #endif } @@ -10246,7 +10246,7 @@ void clif_parse_WisMessage(int fd, struct map_session_data* sd) if (dstsd->state.autotrade) { char output[256]; sprintf(output, "%s is in autotrade mode and cannot receive whispered messages.", dstsd->status.name); - clif->wis_message(fd, map->wisp_server_name, output, (int)strlen(output) + 1); + clif->wis_message(fd, map->wisp_server_name, output, (int)strlen(output)); return; } diff --git a/src/map/intif.c b/src/map/intif.c index 05b1d7c29..da8eedb8d 100644 --- a/src/map/intif.c +++ b/src/map/intif.c @@ -988,7 +988,7 @@ void intif_parse_WisMessage(int fd) { return; } //Success to send whisper. - clif->wis_message(sd->fd, wisp_source, RFIFOP(fd,56),RFIFOW(fd,2)-56); + clif->wis_message(sd->fd, wisp_source, RFIFOP(fd,56),RFIFOW(fd,2)-57); intif_wis_replay(id,0); // success } @@ -1032,9 +1032,9 @@ void mapif_parse_WisToGM(int fd) char mbuf[255] = { 0 }; char *message; - mes_len = RFIFOW(fd,2) - 32; + mes_len = RFIFOW(fd,2) - 33; // Length not including the NUL terminator Assert_retv(mes_len > 0 && mes_len < 32000); - message = (char *) (mes_len >= 255 ? (char *) aMalloc(mes_len) : mbuf); + message = (mes_len >= 255 ? aMalloc(mes_len) : mbuf); permission = RFIFOL(fd,28); safestrncpy(Wisp_name, RFIFOP(fd,4), NAME_LENGTH); diff --git a/src/map/pc.c b/src/map/pc.c index 113638912..ab1e6ebfc 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -11195,7 +11195,7 @@ void pc_scdata_received(struct map_session_data *sd) { time_t exp_time = sd->expiration_time; char tmpstr[1024]; strftime(tmpstr, sizeof(tmpstr) - 1, msg_sd(sd,501), localtime(&exp_time)); // "Your account time limit is: %d-%m-%Y %H:%M:%S." - clif->wis_message(sd->fd, map->wisp_server_name, tmpstr, (int)strlen(tmpstr)+1); + clif->wis_message(sd->fd, map->wisp_server_name, tmpstr, (int)strlen(tmpstr)); pc->expire_check(sd); } |