From 6fd9a2b9b90face77df367866ad750d1be74a64a Mon Sep 17 00:00:00 2001 From: elemeat Date: Tue, 1 Aug 2017 18:15:06 +0800 Subject: [PATCH] Add Elf file as supported matcher archive type --- README.md | 1 + matchers/archive.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index fa3499f..c4d6561 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,7 @@ func main() { - **Z** - `application/x-compress` - **lz** - `application/x-lzip` - **rpm** - `application/x-rpm` +- **elf** - `application/x-executable` #### Font diff --git a/matchers/archive.go b/matchers/archive.go index 2ab30f9..9c1270f 100644 --- a/matchers/archive.go +++ b/matchers/archive.go @@ -24,6 +24,7 @@ var ( TypeZ = newType("Z", "application/x-compress") TypeLz = newType("lz", "application/x-lzip") TypeRpm = newType("rpm", "application/x-rpm") + TypeElf = newType("elf", "application/x-executable") ) var Archive = Map{ @@ -50,6 +51,7 @@ var Archive = Map{ TypeZ: Z, TypeLz: Lz, TypeRpm: Rpm, + TypeElf: Elf, } func Epub(buf []byte) bool { @@ -207,3 +209,9 @@ func Rpm(buf []byte) bool { buf[0] == 0xED && buf[1] == 0xAB && buf[2] == 0xEE && buf[3] == 0xDB } + +func Elf(buf []byte) bool { + return len(buf) > 52 && + buf[0] == 0x7F && buf[1] == 0x45 && + buf[2] == 0x4C && buf[3] == 0x46 +}