Fix UB in NetworkPacket class

This commit is contained in:
sfan5 2023-09-22 21:30:16 +02:00
parent 5109fa7eda
commit d113636a43

@ -63,6 +63,7 @@ void NetworkPacket::putRawPacket(const u8 *data, u32 datasize, session_t peer_id
// split command and datas
m_command = readU16(&data[0]);
if (m_datasize > 0)
memcpy(m_data.data(), &data[2], m_datasize);
}
@ -553,6 +554,7 @@ Buffer<u8> NetworkPacket::oldForgePacket()
{
Buffer<u8> sb(m_datasize + 2);
writeU16(&sb[0], m_command);
if (m_datasize > 0)
memcpy(&sb[2], m_data.data(), m_datasize);
return sb;