Skip to content

Commit

Permalink
fix(handlers): tighten tar header pattern
Browse files Browse the repository at this point in the history
Numeric fields are stored as padded octal numbers, not decimals.
  • Loading branch information
e3krisztian authored and qkaiser committed Oct 9, 2023
1 parent 43c2d34 commit eaa3812
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions unblob/handlers/archive/tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,10 @@ class TarUnixHandler(_TarHandler):
r""
# (pattern would be too big) char name[100]
+ _padded_field(r"[0-7]", 8) # char mode[8]
+ _padded_field(r"[0-9]", 8) # char uid[8]
+ _padded_field(r"[0-9]", 8) # char gid[8]
+ _padded_field(r"[0-9]", 12) # char size[12]
+ _padded_field(r"[0-9]", 12) # char mtime[12]
+ _padded_field(r"[0-7]", 8) # char uid[8]
+ _padded_field(r"[0-7]", 8) # char gid[8]
+ _padded_field(r"[0-7]", 12) # char size[12]
+ _padded_field(r"[0-7]", 12) # char mtime[12]
+ _padded_field(r"[0-7]", 8) # char chksum[8]
+ r"[0-7\x00]" # char typeflag[1] - no extensions
# Extending/dropping typeflag pattern would cover all tar formats,
Expand Down

0 comments on commit eaa3812

Please sign in to comment.