From 32158edb3a6b3516afff18dccd871e00cda9261c Mon Sep 17 00:00:00 2001 From: Hank Donnay Date: Tue, 17 Jan 2023 15:51:11 -0600 Subject: [PATCH] patterns/tar: Support PAX archives (#77) There are two common magic values for archives: the [GNU one](https://git.savannah.gnu.org/cgit/tar.git/tree/src/tar.h#n160) (8 bytes) and the [ustar one](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_06) (6 bytes). This change has the pattern support both. --- patterns/tar.hexpat | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/patterns/tar.hexpat b/patterns/tar.hexpat index 02d98e2..358f067 100644 --- a/patterns/tar.hexpat +++ b/patterns/tar.hexpat @@ -9,7 +9,8 @@ #include -#define HEADER "ustar " +#define GNU_HEADER "ustar " +#define PAX_HEADER "ustar\x00" #define NULL "\x00" fn octal_to_decimal(str value) { @@ -83,6 +84,6 @@ struct tar { }; char magic[6] @ 0x00000101 [[hidden]]; -std::assert(magic == HEADER, "Magic bytes are not correct! Perhaps wrong file?"); +std::assert(magic == PAX_HEADER || magic == GNU_HEADER, "Magic bytes are not correct! Perhaps wrong file?"); tar tar[while(!std::mem::eof())] @ 0x000;