diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2024-12-08 22:36:02 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2024-12-08 22:37:12 +0100 |
commit | 019c4302ad86fd6981e8abc90cd8cb58003b662c (patch) | |
tree | d628782319eda36507fb5f5abcf6225ce9ac631a /plugins/pcap.lua | |
parent | 189bf940342ebf23b15c7f2dfd27d8a4692b34fc (diff) | |
download | hex-019c4302ad86fd6981e8abc90cd8cb58003b662c.tar.gz hex-019c4302ad86fd6981e8abc90cd8cb58003b662c.tar.xz hex-019c4302ad86fd6981e8abc90cd8cb58003b662c.zip |
Handle tiny files gracefullyHEADorigin/mastermaster
Lua detection functions used to cause fatal errors on failure to read.
We could also reconsider treating detection errors as fatal.
Diffstat (limited to 'plugins/pcap.lua')
-rw-r--r-- | plugins/pcap.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/plugins/pcap.lua b/plugins/pcap.lua index a02fc8f..7ad6606 100644 --- a/plugins/pcap.lua +++ b/plugins/pcap.lua @@ -16,11 +16,17 @@ -- local detect = function (c) + if #c < 4 then + return false + end local magic = c:u32 () return magic == 0xa1b2c3d4 or magic == 0xd4c3b2a1 end local detect_ng = function (c) + if #c < 8 then + return false + end local magic = c (9):u32 () return c:u32 () == 0x0a0d0d0a and (magic == 0x1a2b3c4d or magic == 0x4d3c2b1a) |