summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-18 20:12:08 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-18 20:12:08 +0300
commita3e458c6c5d1fc7cda0afcab74ff95f7a63b728a (patch)
treefa759f93777d9439c4787c83b43669dcd865db74 /src/net
parenta044c97c30d014b7b8db7d72b03dc48829e1099a (diff)
downloadmanaverse-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.gz
manaverse-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.bz2
manaverse-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.xz
manaverse-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.zip
Add missing type casts.
Diffstat (limited to 'src/net')
-rw-r--r--src/net/eathena/mail2handler.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/net/eathena/mail2handler.cpp b/src/net/eathena/mail2handler.cpp
index c52a7b5f7..3c412fc4e 100644
--- a/src/net/eathena/mail2handler.cpp
+++ b/src/net/eathena/mail2handler.cpp
@@ -27,6 +27,8 @@
#include "net/eathena/messageout.h"
#include "net/eathena/protocolout.h"
+#include "utils/checkutils.h"
+
#include "resources/item/item.h"
#include "debug.h"
@@ -106,14 +108,19 @@ void Mail2Handler::sendMail(const std::string &to,
return;
const std::string from = localPlayer->getName();
- const int titleSz = title.size();
- const int bodySz = body.size();
- int16_t sz = 2 + 2 + 24 + 24 + 8 + 2 + 2 + titleSz + bodySz;
+ const int titleSz = CAST_S32(title.size());
+ const int bodySz = CAST_S32(body.size());
+ int32_t sz = 2 + 2 + 24 + 24 + 8 + 2 + 2 + titleSz + bodySz;
+ if (sz > INT16_MAX - 4)
+ {
+ reportAlways("Mail message too big");
+ return;
+ }
if (packetVersion >= 20160600)
sz += 4;
createOutPacket(CMSG_MAIL2_SEND_MAIL);
- outMsg.writeInt16(sz, "len");
+ outMsg.writeInt16(CAST_S16(sz), "len");
outMsg.writeString(to, 24, "to");
outMsg.writeString(from, 24, "from");
outMsg.writeInt64(money, "money");