Menu

#164 Generous memory allocation in C/LzmaDec.c LzmaDec_Allocate()

v1.0 (example)
open
nobody
None
5
2015-12-01
2015-11-29
No

LzmaDec_Allocate() takes the user supplied LZMA dictionary size and attempts to allocate that much memory. If huge dictionaries are not used in practice it might make sense to limit the dictionary size to reduce the impact of corrupt files.

ulimit -v 1024000
./bin/7za t /tmp/7ce9143b2ac73fb705f4716e58081daef6032562450c89e51f88d5d1368d8327 

7-Zip (a) [64] 15.09 beta : Copyright (c) 1999-2015 Igor Pavlov : 2015-10-16
p7zip Version 15.09 beta (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,64 bits,12 CPUs x64)

Scanning the drive for archives:
1 file, 74 bytes (1 KiB)

Testing archive: /tmp/7ce9143b2ac73fb705f4716e58081daef6032562450c89e51f88d5d1368d8327
--
Path = /tmp/7ce9143b2ac73fb705f4716e58081daef6032562450c89e51f88d5d1368d8327
Type = lzma

ERROR: Can't allocate required memory!

Archives with Errors: 1
1 Attachments

Discussion

  • Igor Pavlov

    Igor Pavlov - 2015-11-30

    I suppose we can't limit it, if lzma decoder supports big dictionary (up to 4 GB).

     
  • Sean Burford

    Sean Burford - 2015-12-01

    http://linux.die.net/man/1/lzma says lzma supports 4G on decompression, so the current implementation is correct. Not a bug.

     

Log in to post a comment.