summaryrefslogtreecommitdiff
path: root/src
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
parenta044c97c30d014b7b8db7d72b03dc48829e1099a (diff)
downloadmv-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.gz
mv-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.bz2
mv-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.tar.xz
mv-a3e458c6c5d1fc7cda0afcab74ff95f7a63b728a.zip
Add missing type casts.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp2
-rw-r--r--src/net/eathena/mail2handler.cpp15
2 files changed, 12 insertions, 5 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 6c1025650..a8ad2a63f 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -1658,7 +1658,7 @@ impHandler(useItemInv)
{
Item *const item = getItemByInvIndex(param1,
InventoryType::Inventory);
- PlayerInfo::useEquipItem(item, param2, Sfx_true);
+ PlayerInfo::useEquipItem(item, CAST_S16(param2), Sfx_true);
}
else
{
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");