Skip to content

Loading…

Fix parsing of "version needed to extract" field #1

Merged
merged 1 commit into from

2 participants

@Minoru

This field consists of two bytes, upper one indicating host OS and lower one
indicating version of Zip (de)compressor. Tomake sure if one can unpack given
archive it's only lower byte which is needed to be checked, but library used
to check both.

Thank you for nice library!

@Minoru Minoru Fix parsing of "version needed to extract" field
This field consists of two bytes, upper one indicating host OS and lower one
indicating version of Zip (de)compressor. Tomake sure if one can unpack given
archive it's only lower byte which is needed to be checked, but library used
to check both.
3013f62
@Minoru

Re-reading your comment again I discovered that you may have misread the specification, and I didn't notice it and stressed my point with wrong words. Let's try one more time.

There are two values, "version made by" and "version needed to extract", having the same format, which is: two bytes, first one (lower) indicating version and latter one (higher) indicating host OS. Thus we should examine those two bytes separately.

@jgm
Owner

Ok, thanks. I had overlooked the words "mapped as above" in the description of "version needed to extract."

@jgm jgm merged commit 16fa564 into jgm:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 19, 2012
  1. @Minoru

    Fix parsing of "version needed to extract" field

    Minoru committed
    This field consists of two bytes, upper one indicating host OS and lower one
    indicating version of Zip (de)compressor. Tomake sure if one can unpack given
    archive it's only lower byte which is needed to be checked, but library used
    to check both.
Showing with 2 additions and 1 deletion.
  1. +2 −1 Codec/Archive/Zip.hs
View
3 Codec/Archive/Zip.hs
@@ -578,7 +578,8 @@ getFileHeader locals = do
else do
skip 4 -- skip past signature
skip 2 -- version made by
- versionNeededToExtract <- getWord16le
+ versionNeededToExtract <- getWord8
+ skip 1 -- upper byte indicates OS part of "version needed to extract"
unless (versionNeededToExtract <= 20) $
fail "This archive requires zip >= 2.0 to extract."
skip 2 -- general purpose bit flag
Something went wrong with that request. Please try again.