aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/codec/SkPngCodec.cpp
diff options
context:
space:
mode:
authorGravatar Matt Sarett <msarett@google.com>2017-04-26 10:59:48 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-04-26 17:43:38 +0000
commitd59948a1714fe32729c77e3ea54e0992d48e8541 (patch)
tree77c48bc054b6426eddd75e378178317321161418 /src/codec/SkPngCodec.cpp
parentee683655a9a9d57487ab8d4b0b01bb9bc2def144 (diff)
SkPngCodec: Do not return kInvalidConversion on corrupt png
In this case, the fuzzer thinks there is a bug because we are returning kInvalidConversion for a corrupt png file. Bug: skia:6550 Change-Id: I33f588442f5eaa8a4d642e9328750779f9a9ef5d Reviewed-on: https://skia-review.googlesource.com/14324 Commit-Queue: Matt Sarett <msarett@google.com> Reviewed-by: Leon Scroggins <scroggo@google.com>
Diffstat (limited to 'src/codec/SkPngCodec.cpp')
-rw-r--r--src/codec/SkPngCodec.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp
index b6f418fd49..1c5f821c65 100644
--- a/src/codec/SkPngCodec.cpp
+++ b/src/codec/SkPngCodec.cpp
@@ -986,11 +986,11 @@ void SkPngCodec::destroyReadStruct() {
// Getting the pixels
///////////////////////////////////////////////////////////////////////////////
-bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& options,
- SkPMColor ctable[], int* ctableCount) {
+SkCodec::Result SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& options,
+ SkPMColor ctable[], int* ctableCount) {
if (setjmp(PNG_JMPBUF((png_struct*)fPng_ptr))) {
SkCodecPrintf("Failed on png_read_update_info.\n");
- return false;
+ return kInvalidInput;
}
png_read_update_info(fPng_ptr, fInfo_ptr);
@@ -999,7 +999,7 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
fSwizzler.reset(nullptr);
if (!this->initializeColorXform(dstInfo, options.fPremulBehavior)) {
- return false;
+ return kInvalidConversion;
}
// If SkColorSpaceXform directly supports the encoded PNG format, we should skip format
@@ -1020,12 +1020,12 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
}
if (skipFormatConversion && !options.fSubset) {
fXformMode = kColorOnly_XformMode;
- return true;
+ return kSuccess;
}
if (SkEncodedInfo::kPalette_Color == this->getEncodedInfo().color()) {
if (!this->createColorTable(dstInfo, ctableCount)) {
- return false;
+ return kInvalidInput;
}
}
@@ -1033,7 +1033,7 @@ bool SkPngCodec::initializeXforms(const SkImageInfo& dstInfo, const Options& opt
copy_color_table(dstInfo, fColorTable.get(), ctable, ctableCount);
this->initializeSwizzler(dstInfo, options, skipFormatConversion);
- return true;
+ return kSuccess;
}
void SkPngCodec::initializeXformParams() {
@@ -1115,12 +1115,15 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
size_t rowBytes, const Options& options,
SkPMColor ctable[], int* ctableCount,
int* rowsDecoded) {
- if (!conversion_possible(dstInfo, this->getInfo()) ||
- !this->initializeXforms(dstInfo, options, ctable, ctableCount))
- {
+ if (!conversion_possible(dstInfo, this->getInfo())) {
return kInvalidConversion;
}
+ Result result = this->initializeXforms(dstInfo, options, ctable, ctableCount);
+ if (kSuccess != result) {
+ return result;
+ }
+
if (options.fSubset) {
return kUnimplemented;
}
@@ -1133,12 +1136,15 @@ SkCodec::Result SkPngCodec::onGetPixels(const SkImageInfo& dstInfo, void* dst,
SkCodec::Result SkPngCodec::onStartIncrementalDecode(const SkImageInfo& dstInfo,
void* dst, size_t rowBytes, const SkCodec::Options& options,
SkPMColor* ctable, int* ctableCount) {
- if (!conversion_possible(dstInfo, this->getInfo()) ||
- !this->initializeXforms(dstInfo, options, ctable, ctableCount))
- {
+ if (!conversion_possible(dstInfo, this->getInfo())) {
return kInvalidConversion;
}
+ Result result = this->initializeXforms(dstInfo, options, ctable, ctableCount);
+ if (kSuccess != result) {
+ return result;
+ }
+
this->allocateStorage(dstInfo);
int firstRow, lastRow;