summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-03-10 18:53:02 +0000
committerGitHub <noreply@github.com>2019-03-10 18:53:02 +0000
commit3b25b807f33bff885bd840ec0dc9e2d95b392f81 (patch)
tree699acec74f7fcc070666a2e4cb1ddc572ccc3834 /src/network
parent77961aa73d1947a2eabaa832319b7d73db6d13c2 (diff)
downloadminetest-3b25b807f33bff885bd840ec0dc9e2d95b392f81.tar.gz
minetest-3b25b807f33bff885bd840ec0dc9e2d95b392f81.tar.bz2
minetest-3b25b807f33bff885bd840ec0dc9e2d95b392f81.zip
Fix serialization of std::time_t by casting to u64 first (#8353)
Fixes #8332
Diffstat (limited to 'src/network')
-rw-r--r--src/network/clientpackethandler.cpp4
-rw-r--r--src/network/networkpacket.cpp16
-rw-r--r--src/network/networkpacket.h4
3 files changed, 3 insertions, 21 deletions
diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp
index 889002a82..2f5deae2a 100644
--- a/src/network/clientpackethandler.cpp
+++ b/src/network/clientpackethandler.cpp
@@ -408,7 +408,9 @@ void Client::handleCommand_ChatMessage(NetworkPacket *pkt)
return;
}
- *pkt >> chatMessage->sender >> chatMessage->message >> chatMessage->timestamp;
+ u64 timestamp;
+ *pkt >> chatMessage->sender >> chatMessage->message >> timestamp;
+ chatMessage->timestamp = static_cast<std::time_t>(timestamp);
chatMessage->type = (ChatMessageType) message_type;
diff --git a/src/network/networkpacket.cpp b/src/network/networkpacket.cpp
index 6d869e5eb..22c035c5b 100644
--- a/src/network/networkpacket.cpp
+++ b/src/network/networkpacket.cpp
@@ -281,12 +281,6 @@ NetworkPacket& NetworkPacket::operator<<(u64 src)
return *this;
}
-NetworkPacket& NetworkPacket::operator<<(std::time_t src)
-{
- *this << (u64) src;
- return *this;
-}
-
NetworkPacket& NetworkPacket::operator<<(float src)
{
checkDataSize(4);
@@ -372,16 +366,6 @@ NetworkPacket& NetworkPacket::operator>>(u64& dst)
return *this;
}
-NetworkPacket& NetworkPacket::operator>>(std::time_t& dst)
-{
- checkReadOffset(m_read_offset, 8);
-
- dst = readU64(&m_data[m_read_offset]);
-
- m_read_offset += 8;
- return *this;
-}
-
NetworkPacket& NetworkPacket::operator>>(float& dst)
{
checkReadOffset(m_read_offset, 4);
diff --git a/src/network/networkpacket.h b/src/network/networkpacket.h
index 760b51f7a..a8b741374 100644
--- a/src/network/networkpacket.h
+++ b/src/network/networkpacket.h
@@ -19,7 +19,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
-#include <ctime>
#include "util/pointer.h"
#include "util/numeric.h"
#include "networkprotocol.h"
@@ -88,9 +87,6 @@ public:
NetworkPacket &operator>>(u64 &dst);
NetworkPacket &operator<<(u64 src);
- NetworkPacket &operator>>(std::time_t &dst);
- NetworkPacket &operator<<(std::time_t src);
-
NetworkPacket &operator>>(float &dst);
NetworkPacket &operator<<(float src);