mirror of
https://github.com/0x5eal/luau-unzip.git
synced 2025-04-10 17:20:53 +01:00
fix: add temporary fix for high compression ratio files
Currently, we have a hardcoded buffer size of compressed * 4 for the decompressed data, since deflate does not give the true decompressed size (although zip metadata does). So, on files with a very high compression ratio, a buffer overflow is triggered as our destination buffer is not large enough for the entire decompressed data. This temporary fix involves increasing the factor from 4 to 7 for the size estimation. A future fix would involve using the true decompressed size.
This commit is contained in:
parent
b1818de2f2
commit
1f4dd5715b
1 changed files with 4 additions and 1 deletions
|
@ -344,7 +344,10 @@ end
|
||||||
|
|
||||||
--- Main decompression function that processes DEFLATE compressed data
|
--- Main decompression function that processes DEFLATE compressed data
|
||||||
local function uncompress(source: buffer): buffer
|
local function uncompress(source: buffer): buffer
|
||||||
local dest = buffer.create(buffer.len(source) * 4)
|
-- FIXME: This is a temporary solution to avoid a buffer overflow
|
||||||
|
-- We likely want some type of reflection with the zip metadata to
|
||||||
|
-- have a definitive buffer size
|
||||||
|
local dest = buffer.create(buffer.len(source) * 7)
|
||||||
local d = Data.new(source, dest)
|
local d = Data.new(source, dest)
|
||||||
|
|
||||||
repeat
|
repeat
|
||||||
|
|
Loading…
Add table
Reference in a new issue