From 7095f70d0d8969d24541970a363026174d0ac525 Mon Sep 17 00:00:00 2001 From: Valentin Hilbig Date: Wed, 30 Aug 2023 23:17:29 +0200 Subject: [PATCH] header.go prevent otherHeader.rawTLVs being nil If header.Version != otherHeader.Version then otherHeader.rawTLVs is not present. --- header.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/header.go b/header.go index 81ebeb3..209c2cc 100644 --- a/header.go +++ b/header.go @@ -155,11 +155,11 @@ func (header *Header) EqualsTo(otherHeader *Header) bool { if otherHeader == nil { return false } - // TLVs only exist for version 2 - if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) { + if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol { return false } - if header.Version != otherHeader.Version || header.Command != otherHeader.Command || header.TransportProtocol != otherHeader.TransportProtocol { + // TLVs only exist for version 2 + if header.Version == 2 && !bytes.Equal(header.rawTLVs, otherHeader.rawTLVs) { return false } // Return early for header with LOCAL command, which contains no address information