1
0
mirror of https://github.com/garraflavatra/go-fmp.git synced 2025-06-27 20:15:11 +00:00

Return error for sector headers

This commit is contained in:
2025-06-13 12:19:40 +02:00
parent 2748bd9427
commit 7daac38a79
2 changed files with 5 additions and 0 deletions

View File

@ -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 (

View File

@ -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)