Go to file
Leon Scroggins III 83239658f2 Reland "Make SkPngCodec only read as much of the stream as necessary"
(Originally uploaded as 13900.)

Previously, SkPngCodec assumed that the stream only contained one
image, which ended at the end of the stream. It read the stream in
arbitrarily-sized chunks, and then passed that data to libpng for
processing.

If a stream contains more than one image, this may result in reading
beyond the end of the image, making future reads read the wrong data.

Now, SkPngCodec starts by reading 8 bytes at a time. After the
signature, 8 bytes is enough to know which chunk is next and how many
bytes are in the chunk.

When decoding the size, we stop when we reach IDAT, and when decoding
the image, we stop when we reach IEND.

This manual parsing is necessary to support APNG, which is planned in
the future. It also allows us to remove the SK_GOOGLE3_PNG_HACK, which
was a workaround for reading more than necessary at the beginning of
the image.

Add a test that simulates the issue, by decoding a special stream that
reports an error if the codec attempts to read beyond the end.

Temporarily disable the partial decoding tests for png. A larger change
will be necessary to get those working again, and no clients are
currently relying on incrementally decoding PNGs (i.e. decode part of
an image, then decode further with more data).

Include a workaround for older versions of libpng (e.g. 1.2 in
Google3). In older versions, if the row callback is null when the
IDAT header is processed, reading the image will fail. When we see the
IDAT, we save the length and process a recreated IDAT header later,
after the row callback has been set.

Bug: skia:5368
Bug:b/34073812
Test: Existing tests, plus a new test in dm.

Change-Id: I293a4ddc013b82669a8b735062228b26d0bce933
Reviewed-on: https://skia-review.googlesource.com/13984
Commit-Queue: Leon Scroggins <scroggo@google.com>
Reviewed-by: Matt Sarett <msarett@google.com>
2017-04-21 20:49:55 +00:00
animations first cut at a checkbox 2009-10-21 19:41:10 +00:00
bench jumper, implement 2.2 stages with approx_powf 2017-04-21 17:16:07 +00:00
bin bin/fetch-clang-format 2017-03-08 16:43:49 +00:00
debugger Get Debugger app compiling again 2017-01-06 16:18:27 +00:00
dm Switch SkCodec to int for counts and indices 2017-04-17 17:38:35 +00:00
example Add the ability to enable/disable GPU path renderers 2017-02-22 20:29:56 +00:00
experimental Move the ability to access textures, buffers, and image storages out from GrProcessor. 2017-04-04 15:27:44 +00:00
fuzz hide lockpixels api behind flag 2017-04-17 15:33:36 +00:00
gm Use dstColorSpace in SkPictureShader cache key 2017-04-21 19:34:43 +00:00
gn Reland "Make SkPngCodec only read as much of the stream as necessary" 2017-04-21 20:49:55 +00:00
include makeColorSpace() for SkColorFilterShader and SkLightingShader 2017-04-21 19:55:23 +00:00
infra Skip running the 10k shape benchmarks on Radeon ANGLE bots 2017-04-21 20:11:03 +00:00
platform_tools One-liner fix that allows Viewer to switch between Raster and OpenGL 2017-02-23 22:33:36 +00:00
resources Add a test for getFrameInfo on truncated data 2017-04-17 16:35:35 +00:00
samplecode Circular shadow fixes for Flutter. 2017-04-21 15:23:53 +00:00
site Documentation: site/user/api/canvas updated 2017-04-21 14:57:41 +00:00
src Reland "Make SkPngCodec only read as much of the stream as necessary" 2017-04-21 20:49:55 +00:00
tests Reland "Make SkPngCodec only read as much of the stream as necessary" 2017-04-21 20:49:55 +00:00
third_party Check-in vulkan.h into third_party and use that instead of local sdk vulkan.h 2017-04-20 13:09:27 +00:00
tools Enable fence sync support in ES3 test contexts 2017-04-21 19:39:16 +00:00
.clang-format Mark flatennable macros as block beginning/ending in .clang-format 2017-01-09 15:31:36 +00:00
.gitignore Refactor Vulkan support to support Fuchsia 2017-04-05 17:32:09 +00:00
.gn Basic standalone GN configs. 2016-07-21 12:25:45 -07:00
AUTHORS Added support for building for tvOS 2017-03-14 22:55:04 +00:00
BUILD.gn Check-in vulkan.h into third_party and use that instead of local sdk vulkan.h 2017-04-20 13:09:27 +00:00
codereview.settings Make uploading to Gerrit the default for Skia 2016-11-09 19:07:56 +00:00
CONTRIBUTING Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
CQ_COMMITTERS Moved committer list to chrome-infra-auth and deleted it from the repo 2015-09-02 13:37:54 -07:00
DEPS Update build tools to newer gn. 2017-03-17 17:38:58 +00:00
Doxyfile Make the housekeeper upload doxygen to a newer bucket 2016-10-04 13:23:57 -07:00
LICENSE BUG=skia:5602 2016-09-02 11:19:34 -07:00
PRESUBMIT.py Change PRESUBMIT.py to use [Get|Update]DescriptionLines 2017-04-05 12:49:32 +00:00
public.bzl remove vestigle code for lockpixels 2017-04-20 15:15:58 +00:00
README Fix references to https://sites.google.com/site/skiadocs/. 2015-02-03 13:12:54 -02:00
README.chromium Update README.chromium. 2015-06-11 13:19:24 -07:00
whitespace.txt Marker for driver update on Win10 Golo GT610 2017-03-29 14:07:18 +00:00

Skia is a complete 2D graphic library for drawing Text, Geometries, and Images.

See full details, and build instructions, at https://skia.org.