Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: src/woff2.cc

Issue 28363002: [OTS] Fix "continue-stream" handling in the woff2 decoder (Closed) Base URL: http://ots.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This is the implementation of decompression of the proposed WOFF Ultra 5 // This is the implementation of decompression of the proposed WOFF Ultra
6 // Condensed file format. 6 // Condensed file format.
7 7
8 #include <cassert> 8 #include <cassert>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <vector> 10 #include <vector>
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 if ((flags & kWoff2FlagsTransform) != 0) { 819 if ((flags & kWoff2FlagsTransform) != 0) {
820 if (!ReadBase128(file, &transform_length)) { 820 if (!ReadBase128(file, &transform_length)) {
821 return OTS_FAILURE(); 821 return OTS_FAILURE();
822 } 822 }
823 } 823 }
824 uint32_t src_length = transform_length; 824 uint32_t src_length = transform_length;
825 if ((flag_byte >> 6) == 1 || (flag_byte >> 6) == 2) { 825 if ((flag_byte >> 6) == 1 || (flag_byte >> 6) == 2) {
826 if (!ReadBase128(file, &src_length)) { 826 if (!ReadBase128(file, &src_length)) {
827 return OTS_FAILURE(); 827 return OTS_FAILURE();
828 } 828 }
829 } else if ((flag_byte >> 6) == kShortFlagsContinue) {
830 // The compressed data for this table is in a previuos table, so we set
831 // the src_length to zero.
832 src_length = 0;
829 } 833 }
830 // Disallow huge numbers (> 1GB) for sanity. 834 // Disallow huge numbers (> 1GB) for sanity.
831 if (src_length > 1024 * 1024 * 1024 || 835 if (src_length > 1024 * 1024 * 1024 ||
832 transform_length > 1024 * 1024 * 1024 || 836 transform_length > 1024 * 1024 * 1024 ||
833 dst_length > 1024 * 1024 * 1024) { 837 dst_length > 1024 * 1024 * 1024) {
834 return OTS_FAILURE(); 838 return OTS_FAILURE();
835 } 839 }
836 840
837 table->tag = tag; 841 table->tag = tag;
838 table->flags = flags; 842 table->flags = flags;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 offset = Store16(result, offset, (num_tables << 4) - output_search_range); 951 offset = Store16(result, offset, (num_tables << 4) - output_search_range);
948 for (uint16_t i = 0; i < num_tables; ++i) { 952 for (uint16_t i = 0; i < num_tables; ++i) {
949 const Table* table = &tables.at(i); 953 const Table* table = &tables.at(i);
950 offset = StoreU32(result, offset, table->tag); 954 offset = StoreU32(result, offset, table->tag);
951 offset = StoreU32(result, offset, 0); // checksum, to fill in later 955 offset = StoreU32(result, offset, 0); // checksum, to fill in later
952 offset = StoreU32(result, offset, table->dst_offset); 956 offset = StoreU32(result, offset, table->dst_offset);
953 offset = StoreU32(result, offset, table->dst_length); 957 offset = StoreU32(result, offset, table->dst_length);
954 } 958 }
955 std::vector<uint8_t> uncompressed_buf; 959 std::vector<uint8_t> uncompressed_buf;
956 bool continue_valid = false; 960 bool continue_valid = false;
961 const uint8_t* transform_buf = NULL;
957 for (uint16_t i = 0; i < num_tables; ++i) { 962 for (uint16_t i = 0; i < num_tables; ++i) {
958 const Table* table = &tables.at(i); 963 const Table* table = &tables.at(i);
959 uint32_t flags = table->flags; 964 uint32_t flags = table->flags;
960 const uint8_t* src_buf = data + table->src_offset; 965 const uint8_t* src_buf = data + table->src_offset;
961 uint32_t compression_type = flags & kCompressionTypeMask; 966 uint32_t compression_type = flags & kCompressionTypeMask;
962 const uint8_t* transform_buf = NULL;
963 size_t transform_length = table->transform_length; 967 size_t transform_length = table->transform_length;
964 if ((flags & kWoff2FlagsContinueStream) != 0) { 968 if ((flags & kWoff2FlagsContinueStream) != 0) {
965 if (!continue_valid) { 969 if (!continue_valid) {
966 return OTS_FAILURE(); 970 return OTS_FAILURE();
967 } 971 }
968 } else if (compression_type == kCompressionTypeNone) { 972 } else if (compression_type == kCompressionTypeNone) {
969 if (transform_length != table->src_length) { 973 if (transform_length != table->src_length) {
970 return OTS_FAILURE(); 974 return OTS_FAILURE();
971 } 975 }
972 transform_buf = src_buf; 976 transform_buf = src_buf;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 if (transform_buf > &uncompressed_buf[0] + uncompressed_buf.size()) { 1022 if (transform_buf > &uncompressed_buf[0] + uncompressed_buf.size()) {
1019 return OTS_FAILURE(); 1023 return OTS_FAILURE();
1020 } 1024 }
1021 } 1025 }
1022 } 1026 }
1023 1027
1024 return FixChecksums(tables, result); 1028 return FixChecksums(tables, result);
1025 } 1029 }
1026 1030
1027 } // namespace ots 1031 } // namespace ots
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698