Skip to content

Commit 0ed2d8e

Browse files
committed
test: add BIP37 remote crash bug [CVE-2013-5700] test to p2p_filter.py
1 parent f0d6487 commit 0ed2d8e

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

test/functional/p2p_filter.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
MSG_FILTERED_BLOCK,
1212
msg_getdata,
1313
msg_filterload,
14+
msg_filteradd,
1415
msg_filterclear,
1516
)
1617
from test_framework.mininode import (
@@ -103,6 +104,10 @@ def run_test(self):
103104
txid = self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 7)
104105
filter_node.wait_for_tx(txid)
105106

107+
self.log.info("Check that division-by-zero remote crash bug [CVE-2013-5700] is fixed")
108+
filter_node.send_and_ping(msg_filterload(data=b'', nHashFuncs=1))
109+
filter_node.send_and_ping(msg_filteradd(data=b'letstrytocrashthisnode'))
110+
106111

107112
if __name__ == '__main__':
108113
FilterTest().main()

test/functional/test_framework/messages.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,25 @@ def __repr__(self):
13561356
self.data, self.nHashFuncs, self.nTweak, self.nFlags)
13571357

13581358

1359+
class msg_filteradd:
1360+
__slots__ = ("data")
1361+
command = b"filteradd"
1362+
1363+
def __init__(self, data):
1364+
self.data = data
1365+
1366+
def deserialize(self, f):
1367+
self.data = deser_string(f)
1368+
1369+
def serialize(self):
1370+
r = b""
1371+
r += ser_string(self.data)
1372+
return r
1373+
1374+
def __repr__(self):
1375+
return "msg_filteradd(data={})".format(self.data)
1376+
1377+
13591378
class msg_filterclear:
13601379
__slots__ = ()
13611380
command = b"filterclear"

test/functional/test_framework/mininode.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
msg_blocktxn,
3131
msg_cmpctblock,
3232
msg_feefilter,
33+
msg_filteradd,
3334
msg_filterclear,
3435
msg_filterload,
3536
msg_getaddr,
@@ -65,6 +66,7 @@
6566
b"blocktxn": msg_blocktxn,
6667
b"cmpctblock": msg_cmpctblock,
6768
b"feefilter": msg_feefilter,
69+
b"filteradd": msg_filteradd,
6870
b"filterclear": msg_filterclear,
6971
b"filterload": msg_filterload,
7072
b"getaddr": msg_getaddr,
@@ -324,6 +326,7 @@ def on_block(self, message): pass
324326
def on_blocktxn(self, message): pass
325327
def on_cmpctblock(self, message): pass
326328
def on_feefilter(self, message): pass
329+
def on_filteradd(self, message): pass
327330
def on_filterclear(self, message): pass
328331
def on_filterload(self, message): pass
329332
def on_getaddr(self, message): pass

0 commit comments

Comments
 (0)