From caa5e1b2eed5488eac08e6e4b7f129fe6ba2ae1b Mon Sep 17 00:00:00 2001 From: Sam Truzjan Date: Tue, 10 Dec 2013 08:42:26 +0400 Subject: Fix bug in mempty :: Caps We should not include unknown bits in reserved handshake field. Otherwise peer can think that we support extensions we don't support actually. --- src/Network/BitTorrent/Exchange/Message.hs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Network/BitTorrent') diff --git a/src/Network/BitTorrent/Exchange/Message.hs b/src/Network/BitTorrent/Exchange/Message.hs index e1e17e6e..c3f6818f 100644 --- a/src/Network/BitTorrent/Exchange/Message.hs +++ b/src/Network/BitTorrent/Exchange/Message.hs @@ -180,9 +180,9 @@ instance Default Caps where def = Caps 0 {-# INLINE def #-} --- | Monoid under intersection. +-- | Monoid under intersection. 'mempty' includes all known extensions. instance Monoid Caps where - mempty = Caps (-1) + mempty = toCaps [minBound .. maxBound] {-# INLINE mempty #-} mappend (Caps a) (Caps b) = Caps (a .&. b) @@ -578,7 +578,7 @@ instance Default ExtendedCaps where -- | Monoid under intersection: -- --- * The 'mempty' caps include all known extensions; +-- * The 'mempty' caps includes all known extensions; -- -- * the 'mappend' operation is NOT commutative: it return message -- id from the first caps for the extensions existing in both caps. -- cgit v1.2.3