aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkColorSpace_ICC.cpp
diff options
context:
space:
mode:
authorGravatar raftias <raftias@google.com>2016-11-22 13:21:22 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-22 19:15:02 +0000
commit8daef3ebdd71f0a33faa186511d81c951e3917ab (patch)
treea1f49604c9e304338f11415198b6c373efa86368 /src/core/SkColorSpace_ICC.cpp
parenta16ea1821652f2bdf78023abf87b231b304b6064 (diff)
Fixed fuzzer issue with lut16Type A2B ICC profiles
There was no check for if a profile had gamma table with 0 elements. Now it verifies that the table has 2-4096 entries as the ICC specs say. BUG=667695 GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=5124 Change-Id: I36de202e398654ce8dd88e765455b4c4577724d2 Reviewed-on: https://skia-review.googlesource.com/5124 Reviewed-by: Matt Sarett <msarett@google.com> Commit-Queue: Robert Aftias <raftias@google.com>
Diffstat (limited to 'src/core/SkColorSpace_ICC.cpp')
-rw-r--r--src/core/SkColorSpace_ICC.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/SkColorSpace_ICC.cpp b/src/core/SkColorSpace_ICC.cpp
index 4e81c30471..5c5cfe0e9a 100644
--- a/src/core/SkColorSpace_ICC.cpp
+++ b/src/core/SkColorSpace_ICC.cpp
@@ -1079,6 +1079,27 @@ bool load_a2b0_lutn_type(std::vector<SkColorSpace_A2B::Element>* elements, const
inTableEntries = read_big_endian_u16(src + 48);
outTableEntries = read_big_endian_u16(src + 50);
precision = 2;
+
+ constexpr size_t kMaxLut16GammaEntries = 4096;
+ if (inTableEntries < 2) {
+ SkColorSpacePrintf("Too few (%d) input gamma table entries. Must have at least 2.\n",
+ inTableEntries);
+ return false;
+ } else if (inTableEntries > kMaxLut16GammaEntries) {
+ SkColorSpacePrintf("Too many (%d) input gamma table entries. Must have at most %d.\n",
+ inTableEntries, kMaxLut16GammaEntries);
+ return false;
+ }
+
+ if (outTableEntries < 2) {
+ SkColorSpacePrintf("Too few (%d) output gamma table entries. Must have at least 2.\n",
+ outTableEntries);
+ return false;
+ } else if (outTableEntries > kMaxLut16GammaEntries) {
+ SkColorSpacePrintf("Too many (%d) output gamma table entries. Must have at most %d.\n",
+ outTableEntries, kMaxLut16GammaEntries);
+ return false;
+ }
}
const size_t inputOffset = dataOffset;