]> git.ipfire.org Git - thirdparty/libarchive.git/commit
RAR5 reader: fix a potential SIGSEGV on 32-bit builds 1196/head
authorGrzegorz Antoniak <ga@anadoxin.org>
Thu, 9 May 2019 05:00:33 +0000 (07:00 +0200)
committerGrzegorz Antoniak <ga@anadoxin.org>
Thu, 9 May 2019 05:00:33 +0000 (07:00 +0200)
commitd9a8da4d9c89d0048fd46ad62d210ec9ec6e8d9c
tree2ae1f5bf6d6214d391fc84495b5489a1b144e39c
parentee645d6bbfa5d1ad769865a262fd95b398919e08
RAR5 reader: fix a potential SIGSEGV on 32-bit builds

The reader was causing a SIGSEGV when the file has been declaring a
specific dictionary size. Dictionary sizes above 0xFFFFFFFF bytes are
overflowing size_t type on 32-bit builds. In case the file has been
declaring dictionary size of 0x100000000 (so, UINT_MAX+1), the
window_size variable effectively contained value of 0. Later, the memory
allocation function was skipping actual allocation of 0 bytes, but still
tried to unpack the data.

This commit limits the dictionary window size buffer to 64MB, so it
always fits in a size_t variable, and disallows a zero dictionary size
for files in the header processing stage.

One unit test had to be modified after this change.
libarchive/archive_read_support_format_rar5.c
libarchive/test/test_read_format_rar5.c