src/netbase.h: Fix endian in CNetAddr serialization

We've chosen to htons/ntohs explicitly on reading and writing
(I do not know why). But as READWRITE already does an endian swap
on big endian, this means the port number gets switched around,
which was what we were trying to avoid in the first place. So
to make this compatible, serialize it as FLATDATA.
This commit is contained in:
Wladimir J. van der Laan 2014-12-18 22:07:31 +01:00
parent 01f9c3449a
commit aac3205375

View File

@ -162,7 +162,7 @@ class CService : public CNetAddr
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(FLATDATA(ip)); READWRITE(FLATDATA(ip));
unsigned short portN = htons(port); unsigned short portN = htons(port);
READWRITE(portN); READWRITE(FLATDATA(portN));
if (ser_action.ForRead()) if (ser_action.ForRead())
port = ntohs(portN); port = ntohs(portN);
} }