@@ -37,7 +37,13 @@ write es = LBS.concat $ map putEntry es ++ [LBS.replicate (512*2) 0]
37
37
38
38
putEntry :: Entry -> LBS. ByteString
39
39
putEntry entry = case entryContent entry of
40
- NormalFile content size -> LBS. concat [ header, content, padding size ]
40
+ NormalFile content size
41
+ -- size field is 12 bytes long, so in octal format (see 'putOct')
42
+ -- it can hold numbers up to 8Gb
43
+ | size >= 1 `shiftL` (3 * (12 - 1 ))
44
+ , entryFormat entry == V7Format
45
+ -> error " putEntry: support for files over 8Gb is a Ustar extension"
46
+ | otherwise -> LBS. concat [ header, content, padding size ]
41
47
OtherEntryType ' K' _ _
42
48
| entryFormat entry /= GnuFormat -> error " putEntry: long symlink support is a GNU extension"
43
49
OtherEntryType ' L' _ _
@@ -102,10 +108,12 @@ putHeaderNoChkSum Entry {
102
108
, replicate 12 ' \NUL '
103
109
]
104
110
where
105
- numField :: (Integral a , Bits a , Show a ) => FieldWidth -> a -> String
106
- numField = case format of
107
- V7Format -> putOct
108
- _other -> putLarge
111
+ numField :: FieldWidth -> Int64 -> String
112
+ numField w n
113
+ | n >= 0 && n < 1 `shiftL` (3 * (w - 1 ))
114
+ = putOct w n
115
+ | otherwise
116
+ = putLarge w n
109
117
110
118
(typeCode, contentSize, linkTarget,
111
119
deviceMajor, deviceMinor) = case content of
0 commit comments