summaryrefslogtreecommitdiffstats
path: root/libutils
diff options
context:
space:
mode:
authorAntoine Labour <piman@google.com>2014-07-30 16:40:33 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-30 16:40:33 +0000
commit71db714437eba4da29ddb14d58e11da8134715de (patch)
treedb06e169c9e7af08129890c895b2481d44e4d401 /libutils
parent3aacf9fc5a3cb2fc7dd9cb62d3a2c1f980430172 (diff)
parent4bb951a85a4888540caba4f14f18e99917d4c994 (diff)
downloadsystem_core-71db714437eba4da29ddb14d58e11da8134715de.zip
system_core-71db714437eba4da29ddb14d58e11da8134715de.tar.gz
system_core-71db714437eba4da29ddb14d58e11da8134715de.tar.bz2
am 4bb951a8: Merge "BlobCache: fix uninitialized memory" into lmp-dev
* commit '4bb951a85a4888540caba4f14f18e99917d4c994': BlobCache: fix uninitialized memory
Diffstat (limited to 'libutils')
-rw-r--r--libutils/BlobCache.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libutils/BlobCache.cpp b/libutils/BlobCache.cpp
index f00bf14..8edb401 100644
--- a/libutils/BlobCache.cpp
+++ b/libutils/BlobCache.cpp
@@ -213,7 +213,14 @@ status_t BlobCache::flatten(void* buffer, size_t size) const {
memcpy(eheader->mData, keyBlob->getData(), keySize);
memcpy(eheader->mData + keySize, valueBlob->getData(), valueSize);
- byteOffset += align4(entrySize);
+ size_t totalSize = align4(entrySize);
+ if (totalSize > entrySize) {
+ // We have padding bytes. Those will get written to storage, and contribute to the CRC,
+ // so make sure we zero-them to have reproducible results.
+ memset(eheader->mData + keySize + valueSize, 0, totalSize - entrySize);
+ }
+
+ byteOffset += totalSize;
}
return OK;