From 15c8ca9284cf7cb3c9b49167131147b59ad14ac2 Mon Sep 17 00:00:00 2001 From: Matt Morehouse Date: Mon, 21 Aug 2023 15:28:16 -0500 Subject: [PATCH] common: disable node ID check when fuzzing --- common/node_id.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/common/node_id.c b/common/node_id.c index 1d1a1955f..34cda6d54 100644 --- a/common/node_id.c +++ b/common/node_id.c @@ -58,7 +58,11 @@ void fromwire_node_id(const u8 **cursor, size_t *max, struct node_id *id) void towire_node_id(u8 **pptr, const struct node_id *id) { - /* Cheap sanity check */ +#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION + /* Cheap sanity check. For wire fuzzing, we only care about correct + * encoding of node IDs and not whether the IDs are valid, so we disable + * this check while fuzzing. */ assert(id->k[0] == 0x2 || id->k[0] == 0x3); +#endif towire(pptr, id->k, sizeof(id->k)); }