summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJessica Wagantall <jwagantall@cyngn.com>2016-02-02 00:16:59 (GMT)
committerJessica Wagantall <jwagantall@cyngn.com>2016-02-02 00:44:48 (GMT)
commitbf5465acad899336a775c781412fdd65b47ca60b (patch)
tree4952f4146f9b7a155d714db59c75a50c248ef160
parentfb0b85163b5a75e7cd2d4be87bbe4608c022d521 (diff)
parente4c07b52019e1f12beac171017b15360cdf67641 (diff)
downloadandroid_frameworks_minikin-bf5465acad899336a775c781412fdd65b47ca60b.zip
android_frameworks_minikin-bf5465acad899336a775c781412fdd65b47ca60b.tar.gz
android_frameworks_minikin-bf5465acad899336a775c781412fdd65b47ca60b.tar.bz2
Merge tag 'android-6.0.1_r13' into 13.0
Android 6.0.1 release 13 Ticket: CYNGNOS-1522 Change-Id: Ideb7565eb60e7d473884eec8f928142822338fdd
-rw-r--r--libs/minikin/CmapCoverage.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/libs/minikin/CmapCoverage.cpp b/libs/minikin/CmapCoverage.cpp
index 7503372..6431000 100644
--- a/libs/minikin/CmapCoverage.cpp
+++ b/libs/minikin/CmapCoverage.cpp
@@ -29,11 +29,12 @@ namespace android {
// These could perhaps be optimized to use __builtin_bswap16 and friends.
static uint32_t readU16(const uint8_t* data, size_t offset) {
- return data[offset] << 8 | data[offset + 1];
+ return ((uint32_t)data[offset]) << 8 | ((uint32_t)data[offset + 1]);
}
static uint32_t readU32(const uint8_t* data, size_t offset) {
- return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
+ return ((uint32_t)data[offset]) << 24 | ((uint32_t)data[offset + 1]) << 16 |
+ ((uint32_t)data[offset + 2]) << 8 | ((uint32_t)data[offset + 3]);
}
static void addRange(vector<uint32_t> &coverage, uint32_t start, uint32_t end) {
@@ -101,11 +102,13 @@ static bool getCoverageFormat12(vector<uint32_t>& coverage, const uint8_t* data,
const size_t kGroupSize = 12;
const size_t kStartCharCodeOffset = 0;
const size_t kEndCharCodeOffset = 4;
+ const size_t kMaxNGroups = 0xfffffff0 / kGroupSize; // protection against overflow
+ // For all values < kMaxNGroups, kFirstGroupOffset + nGroups * kGroupSize fits in 32 bits.
if (kFirstGroupOffset > size) {
return false;
}
uint32_t nGroups = readU32(data, kNGroupsOffset);
- if (kFirstGroupOffset + nGroups * kGroupSize > size) {
+ if (nGroups >= kMaxNGroups || kFirstGroupOffset + nGroups * kGroupSize > size) {
return false;
}
for (uint32_t i = 0; i < nGroups; i++) {