richardlehane / siegfried

signature-based file format identification
http://www.itforarchivists.com/siegfried
Apache License 2.0
214 stars 30 forks source link

version 1.10.1 - panic: runtime error when reading corrupted file #238

Closed jamesmooneybodleian closed 6 months ago

jamesmooneybodleian commented 6 months ago

Since upgrading to siegfried version 1.10.1 I'm seeing this odd panic error when attempting to read a file. older versions of siegfried appeared to reading the file without issue. The file in question is known to be corrupt, but wanted to highlight the problem of the panic when attempting to read the file.

As the file (13mb) is a real archive, but not sensitive, I would prefer to send it privately if possible?

System details: siegfried 1.10.1 identifiers:

Error message when attempting to read file with siegfried:

`panic: runtime error: slice bounds out of range [-9:]

goroutine 9 [running]: github.com/richardlehane/siegfried/internal/siegreader.(file).Slice(0xc000062c00?, 0xc000369180?, 0x0?) /tmp/siegfried/internal/siegreader/file.go:76 +0x145 github.com/richardlehane/siegfried/internal/siegreader.(Reader).ReadAt(0xc000418780, {0xc000369180, 0x1e, 0x0?}, 0x0?) /tmp/siegfried/internal/siegreader/reader.go:115 +0xa7 archive/zip.(File).findBodyOffset(0xc00013a790) /usr/lib/golang/src/archive/zip/reader.go:340 +0x5b archive/zip.(File).Open(0xc00013a790) /usr/lib/golang/src/archive/zip/reader.go:218 +0x27 github.com/richardlehane/siegfried/internal/containermatcher.(zipReader).SetSource(0xc000407720, 0x417a53?) /tmp/siegfried/internal/containermatcher/zip.go:45 +0x3c github.com/richardlehane/siegfried/internal/containermatcher.(cTest).identify(0xc00003b080, 0xc00017b570, 0xc00006cf20, {0x84ff98, 0xc000407720}, {0xc00037e000, 0x13}) /tmp/siegfried/internal/containermatcher/identify.go:165 +0x2ee github.com/richardlehane/siegfried/internal/containermatcher.(*ContainerMatcher).identify(0xc00017b570, {0x7ffd3b17c547, 0x42}, {0x84ff98, 0xc000407720}, 0x0?, {0x0, 0x0, 0x0}) /tmp/siegfried/internal/containermatcher/identify.go:145 +0x365 created by github.com/richardlehane/siegfried/internal/containermatcher.Matcher.Identify in goroutine 1 /tmp/siegfried/internal/containermatcher/identify.go:43 +0x2d1`

richardlehane commented 6 months ago

many thanks for reporting this @jamesmooneybodleian. I've received the sample file and will try to work out what is going wrong.

richardlehane commented 6 months ago

Hi James, I believe this is fixed with the latest release (1.11.0) but please re-open if recurs.