]> git.ipfire.org Git - thirdparty/libarchive.git/commit
rar4 reader: protect copy_from_lzss_window_to_unp() (#2172)
authorDustin L. Howett <dustin@howett.net>
Thu, 9 May 2024 23:59:17 +0000 (18:59 -0500)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 23:59:17 +0000 (01:59 +0200)
commiteac15e252010c1189a5c0f461364dbe2cd2a68b1
treeaeddb9aad2565116e4e32adea232518b38429cf7
parent576a24205050a0ce5f8209f13bc1d94912797883
rar4 reader: protect copy_from_lzss_window_to_unp() (#2172)

copy_from_lzss_window_to_unp unnecessarily took an `int` parameter where
both of its callers were holding a `size_t`.

A lzss opcode chain could be constructed that resulted in a negative
copy length, which when passed into memcpy would result in a very, very
large positive number.

Switching copy_from_lzss_window_to_unp to take a `size_t` allows it to
properly bounds-check length.

In addition, this patch also ensures that `length` is not itself larger
than the destination buffer.

Security: CVE-2024-20696
libarchive/archive_read_support_format_rar.c