From 03363f1bd81240a6c67c85f4773e7dfa78719643 Mon Sep 17 00:00:00 2001 From: Alvaro Revuelta Date: Tue, 8 Aug 2023 16:22:53 +0200 Subject: [PATCH] fix: fixes out of bounds crash when waku2 is not set (#1895) --- waku/v2/waku_enr/capabilities.nim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/waku/v2/waku_enr/capabilities.nim b/waku/v2/waku_enr/capabilities.nim index a4dcc93013..0045dc57e4 100644 --- a/waku/v2/waku_enr/capabilities.nim +++ b/waku/v2/waku_enr/capabilities.nim @@ -76,6 +76,9 @@ func waku2*(record: TypedRecord): Option[CapabilitiesBitfield] = if field.isNone(): return none(CapabilitiesBitfield) + if field.get().len != 1: + return none(CapabilitiesBitfield) + some(CapabilitiesBitfield(field.get()[0])) proc supportsCapability*(r: Record, cap: Capabilities): bool =