aboutsummaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2017-10-10 00:47:37 +0200
committerSmallJoker <mk939@ymail.com>2018-06-03 17:31:59 +0200
commit9dc1f2d638ddde253fbfac26c856b5da4ea1495f (patch)
treecec9adcf9aebcdd99079f0d543ece6723bda7a90 /src/network
parentd215198fe8dd9f19e8dc815bdf13989520318758 (diff)
downloadminetest-9dc1f2d638ddde253fbfac26c856b5da4ea1495f.tar.gz
minetest-9dc1f2d638ddde253fbfac26c856b5da4ea1495f.tar.bz2
minetest-9dc1f2d638ddde253fbfac26c856b5da4ea1495f.zip
NetworkPacket::putRawPacket: resize m_data to datasize + memcpy
In some cases NetworkPacket was created using default constructor and m_data is not properly sized. This fixed out of bounds memory copy Also use memcpy instead of std::vector affectation to enhance packet creation
Diffstat (limited to 'src/network')
-rw-r--r--src/network/networkpacket.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/network/networkpacket.cpp b/src/network/networkpacket.cpp
index f7a6499dd..8e06ae104 100644
--- a/src/network/networkpacket.cpp
+++ b/src/network/networkpacket.cpp
@@ -58,9 +58,11 @@ void NetworkPacket::putRawPacket(u8 *data, u32 datasize, u16 peer_id)
m_datasize = datasize - 2;
m_peer_id = peer_id;
+ m_data.resize(m_datasize);
+
// split command and datas
m_command = readU16(&data[0]);
- m_data = std::vector<u8>(&data[2], &data[2 + m_datasize]);
+ memcpy(&m_data[0], &data[2], m_datasize);
}
const char* NetworkPacket::getString(u32 from_offset)