Skip to content

Commit 38addd0

Browse files
committed
Fixed unzip crc32 comparison.
1 parent 0574d4a commit 38addd0

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

arch/UNZIP.LUA

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function unzip(p)
4949
-- v = version needed
5050
-- fl = flags
5151
-- cm = Compression method
52-
-- cr = Expected crc32 checksum
52+
-- cr = Calculated crc32 checksum
5353
-- cs = Compressed size
5454
-- us = Uncompressed size
5555
-- nl = Length of file name
@@ -58,16 +58,16 @@ function unzip(p)
5858
-- di = directory
5959
-- of = output file
6060
-- re = remaining bytes
61-
-- cr = crc32 checksum
62-
local s, v, fl, cm, cr, cs, us, nl, el, fn, os, di, of, re = f:read(4)
61+
-- ec = Expected crc32 checksum
62+
local s, v, fl, cm, cr, cs, us, nl, el, fn, di, of, re, ec = f:read(4)
6363
if not s or #s < 4 then break end
6464
if s ~= "PK\3\4" then break end
6565

6666
v , E = R16() D() -- version
6767
fl, E = R16() D() -- flags
6868
cm, E = R16() D() -- method
6969
S(4) -- skip modification time and date
70-
cr, E = R32() D() -- crc32
70+
ec, E = R32() D() -- crc32
7171
cs, E = R32() D() -- compressed size
7272
us, E = R32() D() -- uncompressed size
7373
nl, E = R16() D() -- name length
@@ -78,7 +78,7 @@ function unzip(p)
7878

7979
print("Extracting: " .. fn)
8080

81-
re, cr = cs, 0
81+
re = cs
8282

8383
---Read compressed data in chunks
8484
local function RC()
@@ -119,7 +119,7 @@ function unzip(p)
119119

120120
of:close()
121121

122-
if cr ~= cr then print("!CRC") end
122+
if ec ~= cr then print("!CRC") end
123123
end
124124
end
125125

0 commit comments

Comments
 (0)