mirror of
https://github.com/minetest/minetest.git
synced 2024-11-30 03:23:45 +01:00
Fix UB in NetworkPacket class
This commit is contained in:
parent
5109fa7eda
commit
d113636a43
@ -63,7 +63,8 @@ void NetworkPacket::putRawPacket(const u8 *data, u32 datasize, session_t peer_id
|
|||||||
|
|
||||||
// split command and datas
|
// split command and datas
|
||||||
m_command = readU16(&data[0]);
|
m_command = readU16(&data[0]);
|
||||||
memcpy(m_data.data(), &data[2], m_datasize);
|
if (m_datasize > 0)
|
||||||
|
memcpy(m_data.data(), &data[2], m_datasize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkPacket::clear()
|
void NetworkPacket::clear()
|
||||||
@ -553,7 +554,8 @@ Buffer<u8> NetworkPacket::oldForgePacket()
|
|||||||
{
|
{
|
||||||
Buffer<u8> sb(m_datasize + 2);
|
Buffer<u8> sb(m_datasize + 2);
|
||||||
writeU16(&sb[0], m_command);
|
writeU16(&sb[0], m_command);
|
||||||
memcpy(&sb[2], m_data.data(), m_datasize);
|
if (m_datasize > 0)
|
||||||
|
memcpy(&sb[2], m_data.data(), m_datasize);
|
||||||
|
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user