diff options
author | Andrei Karas <akaras@inbox.ru> | 2018-11-15 23:58:28 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2018-12-12 21:18:05 +0300 |
commit | af9e75a46245eee406eb1b9d7b3c98181b3a9cc4 (patch) | |
tree | b26a11ccaf74541e8abdc5f9ca676b2df6a1db97 /src/char/char.c | |
parent | 619dcd43d2419f83d99c4dd82b9e37e01cfd0c63 (diff) | |
download | hercules-af9e75a46245eee406eb1b9d7b3c98181b3a9cc4.tar.gz hercules-af9e75a46245eee406eb1b9d7b3c98181b3a9cc4.tar.bz2 hercules-af9e75a46245eee406eb1b9d7b3c98181b3a9cc4.tar.xz hercules-af9e75a46245eee406eb1b9d7b3c98181b3a9cc4.zip |
Add validation for buffer size in char_mmo_char_tobuf.
And use correct MAX_CHAR_BUF
Diffstat (limited to 'src/char/char.c')
-rw-r--r-- | src/char/char.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/char/char.c b/src/char/char.c index a09eccd8a..023ab0ade 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -21,7 +21,7 @@ #define HERCULES_CORE #include "config/core.h" // CONSOLE_INPUT -#include "char.h" +#include "char/char.h" #include "char/HPMchar.h" #include "char/geoip.h" @@ -53,6 +53,7 @@ #include "common/mapindex.h" #include "common/mmo.h" #include "common/nullpo.h" +#include "common/packetsstatic_len.h" #include "common/showmsg.h" #include "common/socket.h" #include "common/strlib.h" @@ -1987,7 +1988,7 @@ static int char_count_users(void) // Writes char data to the buffer in the format used by the client. // Used in packets 0x6b (chars info) and 0x6d (new char info) // Returns the size -#define MAX_CHAR_BUF 150 //Max size (for WFIFOHEAD calls) +#define MAX_CHAR_BUF (PACKET_LEN_0x006d - 2) static int char_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p) { unsigned short offset = 0; @@ -2092,7 +2093,9 @@ static int char_mmo_char_tobuf(uint8 *buffer, struct mmo_charstatus *p) #endif #endif - return 106+offset; + if (106 + offset != MAX_CHAR_BUF) + Assert_report("Wrong buffer size in char_mmo_char_tobuf"); + return 106 + offset; } /* Made Possible by Yommy~! <3 */ |