h2non / filetype

Fast, dependency-free Go package to infer binary file types based on the magic numbers header signature

Home Page:https://pkg.go.dev/github.com/h2non/filetype?tab=doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tar filetype doesn't match for Pre-POSIX.1-1988 tar headers

DiscordSaver opened this issue · comments

Was testing against a large collection of archive files and noticed it wouldn't flag certain tar files a tar file. After researching it turns out those files were Pre-POSIX. You can grab a sample file from https://getsamplefiles.com/sample-archive-files/tar

Yeah, that's true. Pre-posix (also known as v7) tar doesn't have magic field filled in its header block. The way the tools like tar, file, etc deal with it is they calculate the block's (512 bytes) checksum and then compare it with stored value. It requires a but if code but in principle, it is not hard to add and I'm happy to send a PR if you think it worth it.