Skip to content

Commit fb7a657

Browse files
committed
Insist that OtherEntryType 'K' mandates GnuFormat
1 parent ef61ce8 commit fb7a657

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

Codec/Archive/Tar/Write.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ write es = LBS.concat $ map putEntry es ++ [LBS.replicate (512*2) 0]
3838
putEntry :: Entry -> LBS.ByteString
3939
putEntry entry = case entryContent entry of
4040
NormalFile content size -> LBS.concat [ header, content, padding size ]
41+
OtherEntryType 'K' _ _
42+
| entryFormat entry /= GnuFormat -> error "putEntry: long symlink support is a GNU extension"
4143
OtherEntryType 'L' _ _
4244
| entryFormat entry /= GnuFormat -> error "putEntry: long filename support is a GNU extension"
4345
OtherEntryType _ content size -> LBS.concat [ header, content, padding size ]

test/Codec/Archive/Tar/Types/Tests.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ instance (Arbitrary tarPath, Arbitrary linkTarget) => Arbitrary (GenEntry tarPat
8585
entryOwnership <- arbitrary
8686
entryTime <- arbitraryOctal 11
8787
entryFormat <- case entryContent of
88+
OtherEntryType 'K' _ _ -> pure GnuFormat
8889
OtherEntryType 'L' _ _ -> pure GnuFormat
8990
_ -> arbitrary
9091
pure Entry{..}

0 commit comments

Comments
 (0)