From 8fbcb8562fcd58943cbc1d7c2ae9b872fa81c6b0 Mon Sep 17 00:00:00 2001 From: Thomas Klaehn Date: Fri, 13 Feb 2026 10:15:45 +0100 Subject: [PATCH] Fix: Header crc calculation Signed-off-by: Thomas Klaehn --- fitparser/header.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/fitparser/header.go b/fitparser/header.go index 3cf4fb7..f2824a7 100644 --- a/fitparser/header.go +++ b/fitparser/header.go @@ -54,10 +54,12 @@ func ParseHeader(data []byte) (*Header, error) { if h.Size == HeaderWithCRCSize { h.CRC = binary.LittleEndian.Uint16(data[12:14]) - // Validate header CRC - calculatedCRC := CalculateCRC(data[0:12]) - if calculatedCRC != h.CRC { - return nil, fmt.Errorf("header CRC mismatch: got 0x%04X, expected 0x%04X", h.CRC, calculatedCRC) + // Validate header CRC (skip if CRC is 0x0000, which means "no validation") + if h.CRC != 0x0000 { + calculatedCRC := CalculateCRC(data[0:12]) + if calculatedCRC != h.CRC { + return nil, fmt.Errorf("header CRC mismatch: got 0x%04X, expected 0x%04X", h.CRC, calculatedCRC) + } } }