Stop supporting kUnknown_BmpHeaderType
authorLeon Scroggins III <scroggo@google.com>
Thu, 15 Dec 2016 20:58:22 +0000 (15:58 -0500)
committerSkia Commit-Bot <skia-commit-bot@chromium.org>
Thu, 15 Dec 2016 21:48:03 +0000 (21:48 +0000)
commit0b24cbd9db8b894fdabce7a27f5369b320bee7f1
treefc8c1dcb7e098acec2b82e7e53ae9f62fa5d8c59
parent6b00a07d4fa5f9fd2feb0fc50adac0ce6a477e41
Stop supporting kUnknown_BmpHeaderType

In SkBmpCodec, if the header size does not match a known header,
stop trying to create an SkCodec. We do not know of any BMPs with
arbitrarily sized headers, so this should not cause any real
regressions.

In addition, this fixes a bug where we attempt to read too much data
from a file. Since we attempt to read the header size in one read,
and a size reported by the "BMP" may be larger than SSIZE_MAX, this
will crash when reading from a file.

Add a test.

BUG:b/33651913

Change-Id: I0f3292db3124dc5ac5cbdbc07196bda130a49ba7
Reviewed-on: https://skia-review.googlesource.com/6150
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
resources/invalid_images/b33651913.bmp [new file with mode: 0644]
src/codec/SkBmpCodec.cpp
tests/CodecTest.cpp