diff --git a/Codec/Archive/Zip/Conduit/Internal.hs b/Codec/Archive/Zip/Conduit/Internal.hs index f3c0733..1037c53 100644 --- a/Codec/Archive/Zip/Conduit/Internal.hs +++ b/Codec/Archive/Zip/Conduit/Internal.hs @@ -1,5 +1,5 @@ module Codec.Archive.Zip.Conduit.Internal - ( zipVersion + ( osVersion, zipVersion , zipError , idConduit , sizeCRC @@ -15,14 +15,18 @@ import qualified Data.ByteString as BS import qualified Data.Conduit as C import qualified Data.Conduit.Internal as CI import Data.Digest.CRC32 (crc32Update) -import Data.Word (Word16, Word32, Word64) +import Data.Word (Word8, Word16, Word32, Word64) import Codec.Archive.Zip.Conduit.Types --- |The version of this zip program, really just rough indicator of compatibility -zipVersion :: Word16 +-- | The version of this zip program, really just rough indicator of compatibility +zipVersion :: Word8 zipVersion = 48 +-- | The OS this implementation tries to be compatible to +osVersion :: Word8 +osVersion = 0 -- DOS + zipError :: MonadThrow m => String -> m a zipError = throwM . ZipError diff --git a/Codec/Archive/Zip/Conduit/UnZip.hs b/Codec/Archive/Zip/Conduit/UnZip.hs index 62a5a0f..f2a5c66 100644 --- a/Codec/Archive/Zip/Conduit/UnZip.hs +++ b/Codec/Archive/Zip/Conduit/UnZip.hs @@ -151,7 +151,8 @@ unZipStream = next where centralBody 0x06054b50 = EndOfCentralDirectory <$> endDirectory centralBody sig = fail $ "Unknown header signature: " ++ show sig fileHeader = do - ver <- G.getWord16le + G.getWord8 -- OS Version + ver <- G.getWord8 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 6cfbe7e..9977fd1 100644 --- a/Codec/Archive/Zip/Conduit/Zip.hs +++ b/Codec/Archive/Zip/Conduit/Zip.hs @@ -165,7 +165,8 @@ zipStream ZipOptions{..} = execStateC 0 $ do l64 = z64 ?* 16 + o64 ?* 8 a64 = z64 || o64 P.putWord32le 0x02014b50 - P.putWord16le zipVersion + P.putWord8 osVersion + P.putWord8 zipVersion P.putWord16le $ if a64 then 45 else 20 common P.putWord32le crc @@ -192,7 +193,8 @@ zipStream ZipOptions{..} = execStateC 0 $ do when z64 $ output $ do P.putWord32le 0x06064b50 -- zip64 end P.putWord64le 44 -- length of this record - P.putWord16le zipVersion + P.putWord8 osVersion + P.putWord8 zipVersion P.putWord16le 45 P.putWord32le 0 -- disk P.putWord32le 0 -- central disk