diff --git a/Codec/Archive/Zip/Conduit/UnZip.hs b/Codec/Archive/Zip/Conduit/UnZip.hs index f2a5c66..7ce313e 100644 --- a/Codec/Archive/Zip/Conduit/UnZip.hs +++ b/Codec/Archive/Zip/Conduit/UnZip.hs @@ -151,8 +151,8 @@ unZipStream = next where centralBody 0x06054b50 = EndOfCentralDirectory <$> endDirectory centralBody sig = fail $ "Unknown header signature: " ++ show sig fileHeader = do - G.getWord8 -- OS Version ver <- G.getWord8 + G.getWord8 -- OS Version when (ver > zipVersion) $ fail $ "Unsupported version: " ++ show ver gpf <- G.getWord16le -- when (gpf .&. complement (bit 1 .|. bit 2 .|. bit 3) /= 0) $ fail $ "Unsupported flags: " ++ show gpf diff --git a/Codec/Archive/Zip/Conduit/Zip.hs b/Codec/Archive/Zip/Conduit/Zip.hs index 9977fd1..7bf80b0 100644 --- a/Codec/Archive/Zip/Conduit/Zip.hs +++ b/Codec/Archive/Zip/Conduit/Zip.hs @@ -129,7 +129,8 @@ zipStream ZipOptions{..} = execStateC 0 $ do off <- get output $ do P.putWord32le 0x04034b50 - P.putWord16le $ if z64 then 45 else 20 + P.putWord8 $ if z64 then 45 else 20 + P.putWord8 osVersion common P.putWord32le $ fromMaybe 0 mcrc P.putWord32le $ if z64 then maxBound32 else maybe 0 fromIntegral csiz @@ -165,9 +166,10 @@ zipStream ZipOptions{..} = execStateC 0 $ do l64 = z64 ?* 16 + o64 ?* 8 a64 = z64 || o64 P.putWord32le 0x02014b50 - P.putWord8 osVersion P.putWord8 zipVersion - P.putWord16le $ if a64 then 45 else 20 + P.putWord8 osVersion + P.putWord8 $ if a64 then 45 else 20 + P.putWord8 osVersion common P.putWord32le crc P.putWord32le $ if z64 then maxBound32 else fromIntegral csz @@ -193,9 +195,10 @@ zipStream ZipOptions{..} = execStateC 0 $ do when z64 $ output $ do P.putWord32le 0x06064b50 -- zip64 end P.putWord64le 44 -- length of this record - P.putWord8 osVersion P.putWord8 zipVersion - P.putWord16le 45 + P.putWord8 osVersion + P.putWord8 45 + P.putWord8 osVersion P.putWord32le 0 -- disk P.putWord32le 0 -- central disk P.putWord64le cnt