aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/CodecTest.cpp
diff options
context:
space:
mode:
authorGravatar Leon Scroggins III <scroggo@google.com>2018-02-13 16:41:03 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-13 22:05:53 +0000
commitfee7cbaf44553dda1a0dd4bfc87a1dfc0d7dd369 (patch)
treebb2150dcf14cba34c4f1d6c31c7d3dc3930afacd /tests/CodecTest.cpp
parentffdf3ec88065d43004100a55cffca2d0c6875b38 (diff)
Check the length of marker before reading it
Bug: os-fuzz:6295 Change-Id: I0ea9a3c54d61d41f21f2e9b945ab83fa2beb00d8 Reviewed-on: https://skia-review.googlesource.com/107025 Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'tests/CodecTest.cpp')
-rw-r--r--tests/CodecTest.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/tests/CodecTest.cpp b/tests/CodecTest.cpp
index df94547600..8172751cf6 100644
--- a/tests/CodecTest.cpp
+++ b/tests/CodecTest.cpp
@@ -621,14 +621,20 @@ DEF_TEST(Codec_Dimensions, r) {
}
static void test_invalid(skiatest::Reporter* r, const char path[]) {
- std::unique_ptr<SkStream> stream(GetResourceAsStream(path));
- if (!stream) {
+ auto data = GetResourceAsData(path);
+ if (!data) {
+ ERRORF(r, "Failed to get resources %s", path);
return;
}
- REPORTER_ASSERT(r, !SkCodec::MakeFromStream(std::move(stream)));
+
+ REPORTER_ASSERT(r, !SkCodec::MakeFromData(data));
}
DEF_TEST(Codec_Empty, r) {
+ if (GetResourcePath().isEmpty()) {
+ return;
+ }
+
// Test images that should not be able to create a codec
test_invalid(r, "empty_images/zero-dims.gif");
test_invalid(r, "empty_images/zero-embedded.ico");
@@ -648,6 +654,7 @@ DEF_TEST(Codec_Empty, r) {
test_invalid(r, "empty_images/zero_height.tiff");
#endif
test_invalid(r, "invalid_images/b37623797.ico");
+ test_invalid(r, "invalid_images/osfuzz6295.webp");
}
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED