Skip to content

Commit 2d0dce0

Browse files
committed
net_processing: fix BIP152 first integer interpretation
1 parent 1e169a8 commit 2d0dce0

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/net_processing.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3935,10 +3935,17 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
39353935
}
39363936

39373937
if (msg_type == NetMsgType::SENDCMPCT) {
3938-
bool sendcmpct_hb{false};
3938+
uint8_t sendcmpct_hb{0};
39393939
uint64_t sendcmpct_version{0};
39403940
vRecv >> sendcmpct_hb >> sendcmpct_version;
39413941

3942+
// BIP152: the first integer is interpreted as a boolean and MUST have a
3943+
// value of either 1 or 0.
3944+
if (sendcmpct_hb > 1) {
3945+
Misbehaving(peer, "invalid sendcmpct announce field");
3946+
return;
3947+
}
3948+
39423949
// Only support compact block relay with witnesses
39433950
if (sendcmpct_version != CMPCTBLOCKS_VERSION) return;
39443951

0 commit comments

Comments
 (0)