convertbmp: detect invalid file dimensions early 1172/head
authorHugo Lefeuvre <hle@debian.org>
Fri, 14 Dec 2018 03:58:40 +0000 (04:58 +0100)
committerHugo Lefeuvre <hle@debian.org>
Fri, 14 Dec 2018 04:10:35 +0000 (05:10 +0100)
commit8ee335227bbcaf1614124046aa25e53d67b11ec3
tree334e85bf3473e5fd9ac7532ff746bbeaa6bef9f3
parente7640f58f122d1228f3d750864543ad4703e18fc
convertbmp: detect invalid file dimensions early

width/length dimensions read from bmp headers are not necessarily
valid. For instance they may have been maliciously set to very large
values with the intention to cause DoS (large memory allocation, stack
overflow). In these cases we want to detect the invalid size as early
as possible.

This commit introduces a counter which verifies that the number of
written bytes corresponds to the advertized width/length.

Fixes #1059 (CVE-2018-6616).
src/bin/jp2/convertbmp.c