convertbmp: detect invalid file dimensions early
authorYoung Xiao <YangX92@hotmail.com>
Sat, 16 Mar 2019 11:57:27 +0000 (19:57 +0800)
committerYoung Xiao <92siuyang@gmail.com>
Mon, 15 Apr 2019 08:10:18 +0000 (16:10 +0800)
commit21399f6b7d318fcdf4406d5e88723c4922202aa3
treebb5cdf4d2a0fdf1e2cc3338732d2ea66cde13190
parentd0dd894ae24d0f2f09072adf1b966033dd64672d
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.

See commit 8ee335227bbc for details.

Signed-off-by: Young Xiao <YangX92@hotmail.com>
src/bin/jp2/convertbmp.c