From 41cf7e25207005b9fb4726d78cf45ee4070ccefc Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 6 Oct 2017 14:34:17 -0700 Subject: libwebp: cherry-pick demux fix demux,StoreFrame: restore hdr size check to min req avoids over reading if the reported ANMF payload is < 8 bytes. likely broken since: 81b8a741 Design change in ANMF and FRGM chunks: Test: compiles BUG=b/67381469,b/67430073 Change-Id: Ibd646f391413dc8f77169259a5c58ddbe2911bdd --- README.android | 1 + src/demux/demux.c | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.android b/README.android index f1338b36..28d513b9 100644 --- a/README.android +++ b/README.android @@ -12,6 +12,7 @@ Local modifications: These files are not required to build via Android.mk - Undefine WEBP_ANDROID_NEON on Android targets and use __ARM_NEON__ instead. +- cherry-pick 7038ca8d demux,StoreFrame: restore hdr size check to min req The Android.mk file creates WebP decoder and encoder static libraries which can be added to any application by adding to LOCAL_STATIC_LIBRARIES diff --git a/src/demux/demux.c b/src/demux/demux.c index 100eab8c..567ba3d4 100644 --- a/src/demux/demux.c +++ b/src/demux/demux.c @@ -205,12 +205,14 @@ static void SetFrameInfo(size_t start_offset, size_t size, frame->complete_ = complete; } -// Store image bearing chunks to 'frame'. +// Store image bearing chunks to 'frame'. 'min_size' is an optional size +// requirement, it may be zero. static ParseStatus StoreFrame(int frame_num, uint32_t min_size, MemBuffer* const mem, Frame* const frame) { int alpha_chunks = 0; int image_chunks = 0; - int done = (MemDataSize(mem) < min_size); + int done = (MemDataSize(mem) < CHUNK_HEADER_SIZE || + MemDataSize(mem) < min_size); ParseStatus status = PARSE_OK; if (done) return PARSE_NEED_MORE_DATA; @@ -401,9 +403,9 @@ static ParseStatus ParseSingleImage(WebPDemuxer* const dmux) { frame = (Frame*)WebPSafeCalloc(1ULL, sizeof(*frame)); if (frame == NULL) return PARSE_ERROR; - // For the single image case we allow parsing of a partial frame, but we need - // at least CHUNK_HEADER_SIZE for parsing. - status = StoreFrame(1, CHUNK_HEADER_SIZE, &dmux->mem_, frame); + // For the single image case we allow parsing of a partial frame, so no + // minimum size is imposed here. + status = StoreFrame(1, 0, &dmux->mem_, frame); if (status != PARSE_ERROR) { const int has_alpha = !!(dmux->feature_flags_ & ALPHA_FLAG); // Clear any alpha when the alpha flag is missing. -- cgit v1.2.3 From 51e0229c3b998865d503f1a74663a2e2defaaea3 Mon Sep 17 00:00:00 2001 From: Derek Sollenberger Date: Wed, 31 Jan 2018 13:18:10 -0500 Subject: Add the sdk_version that this should be built against. Setting this enables our testing tools that must be SDK/NDK compliant to include these static libs in their builds. Bug: 74442448 Test: compile and CtsSkQPTestCases Change-Id: If5e9da6392999767f7aec717d5c928bfb45385fc --- Android.bp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Android.bp b/Android.bp index d54c8796..737a3c27 100644 --- a/Android.bp +++ b/Android.bp @@ -109,6 +109,8 @@ cc_library_static { local_include_dirs: ["."], static_libs: ["webp-headers"], export_static_lib_headers: ["webp-headers"], + + sdk_version: "9", } //############################################## -- cgit v1.2.3