aboutsummaryrefslogtreecommitdiff
path: root/test/functional
diff options
context:
space:
mode:
authorW. J. van der Laan <laanwj@protonmail.com>2021-05-06 17:25:17 +0200
committerW. J. van der Laan <laanwj@protonmail.com>2021-05-06 17:30:52 +0200
commit955eee76803c098978cf0bbc7f1f6d3c230544e2 (patch)
tree43972207a367ea0b51cd416ff94ab9c315a24071 /test/functional
parent9c05da4a5c57d7fd0fc53817ad6f0a07c0f08b5b (diff)
downloadbitcoin-955eee76803c098978cf0bbc7f1f6d3c230544e2.tar.xz
net: Sanitize message type for logging
- Use `SanitizeString` when logging message errors to make sure that the message type is sanitized. - For the `MESSAGESTART` error don't inspect and log header details at all: receiving invalid start bytes makes it likely that the packet isn't even formatted as valid P2P message. Logging the four unexpected start bytes should be enough. - Update `p2p_invalid_messages.py` test to check this. Issue reported by gmaxwell.
Diffstat (limited to 'test/functional')
-rwxr-xr-xtest/functional/p2p_invalid_messages.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/test/functional/p2p_invalid_messages.py b/test/functional/p2p_invalid_messages.py
index c0b3c2cb12..c81886a982 100755
--- a/test/functional/p2p_invalid_messages.py
+++ b/test/functional/p2p_invalid_messages.py
@@ -37,7 +37,7 @@ VALID_DATA_LIMIT = MAX_PROTOCOL_MESSAGE_LENGTH - 5 # Account for the 5-byte len
class msg_unrecognized:
"""Nonsensical message. Modeled after similar types in test_framework.messages."""
- msgtype = b'badmsg'
+ msgtype = b'badmsg\x01'
def __init__(self, *, str_data):
self.str_data = str_data.encode() if not isinstance(str_data, bytes) else str_data
@@ -104,7 +104,7 @@ class InvalidMessagesTest(BitcoinTestFramework):
def test_magic_bytes(self):
self.log.info("Test message with invalid magic bytes disconnects peer")
conn = self.nodes[0].add_p2p_connection(P2PDataStore())
- with self.nodes[0].assert_debug_log(['HEADER ERROR - MESSAGESTART (badmsg, 2 bytes), received ffffffff']):
+ with self.nodes[0].assert_debug_log(['HEADER ERROR - MESSAGESTART received ffffffff']):
msg = conn.build_message(msg_unrecognized(str_data="d"))
# modify magic bytes
msg = b'\xff' * 4 + msg[4:]