From: Manuel Nickschas Date: Wed, 3 Feb 2016 23:10:08 +0000 (+0100) Subject: Don't serialize PeerPtr value in RPC connections X-Git-Tag: 0.12.3~7 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=811bb7461e2a22f24904d58f0b02f860e12ffe5b Don't serialize PeerPtr value in RPC connections PeerPtr is used in RPC signatures for enabling receivers to send replies to a particular peer rather than broadcast to all connected ones. To enable this, the SignalProxy transparently replaces the bogus value received over the network with the actual address of the local Peer instance. Because the actual value isn't needed on the wire, it should be serialized as null. This also prevents the accidental use of a bogus remote pointer address. --- diff --git a/src/common/peer.cpp b/src/common/peer.cpp index 3785326c..c076806f 100644 --- a/src/common/peer.cpp +++ b/src/common/peer.cpp @@ -34,20 +34,23 @@ AuthHandler *Peer::authHandler() const } -// Note that we need to use a fixed-size integer instead of uintptr_t, in order -// to avoid issues with different architectures for client and core. -// In practice, we'll never really have to restore the real value of a PeerPtr from -// a QVariant. +// PeerPtr is used in RPC signatures for enabling receivers to send replies +// to a particular peer rather than broadcast to all connected ones. +// To enable this, the SignalProxy transparently replaces the bogus value +// received over the network with the actual address of the local Peer +// instance. Because the actual value isn't needed on the wire, it is +// serialized as null. QDataStream &operator<<(QDataStream &out, PeerPtr ptr) { - out << reinterpret_cast(ptr); + Q_UNUSED(ptr); + out << static_cast(0); // 64 bit for historic reasons return out; } QDataStream &operator>>(QDataStream &in, PeerPtr &ptr) { + ptr = nullptr; quint64 value; in >> value; - ptr = reinterpret_cast(value); return in; }