From 7daac38a79fa7a352adca64b3d32ceac9bff9095 Mon Sep 17 00:00:00 2001 From: Romein van Buren Date: Fri, 13 Jun 2025 12:19:40 +0200 Subject: [PATCH] Return error for sector headers --- fmp/fmp_const.go | 1 + fmp/fmp_file.go | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/fmp/fmp_const.go b/fmp/fmp_const.go index 82426cd..8c89012 100644 --- a/fmp/fmp_const.go +++ b/fmp/fmp_const.go @@ -11,6 +11,7 @@ var ( ErrBadHeader = FmpError("bad header") ErrUnsupportedCharset = FmpError("unsupported character set") ErrBadSectorCount = FmpError("bad sector count") + ErrBadSectorHeader = FmpError("bad sector header") ) const ( diff --git a/fmp/fmp_file.go b/fmp/fmp_file.go index 1db4053..966c494 100644 --- a/fmp/fmp_file.go +++ b/fmp/fmp_file.go @@ -147,6 +147,10 @@ func (ctx *FmpFile) readSector() (*FmpSector, error) { NextID: parseVarUint64(buf[8 : 8+4]), } + if ctx.currentSectorID == 0 && sector.PrevID > 0 { + return nil, ErrBadSectorHeader + } + payload := make([]byte, sectorPayloadSize) n, err = ctx.stream.Read(payload)