diff options
author | Wonsik Kim <wonsik@google.com> | 2015-09-16 22:33:11 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-16 22:33:11 +0000 |
commit | 4d27a468c09bebe8c5f179af4a66882f01d55644 (patch) | |
tree | 0c22425637efc13275435df057e6bfa2c0beb48b /media/libstagefright/foundation | |
parent | f7c401634ee821a9b04b068a7121cd5386a189f0 (diff) | |
parent | 92efd0c559d4d78880fc06544c662129fe7f6e1d (diff) | |
download | frameworks_av-4d27a468c09bebe8c5f179af4a66882f01d55644.zip frameworks_av-4d27a468c09bebe8c5f179af4a66882f01d55644.tar.gz frameworks_av-4d27a468c09bebe8c5f179af4a66882f01d55644.tar.bz2 |
am 92efd0c5: am b5611b84: Merge "Revert "Avoid size_t overflow in base64 decoding once again"" into lmp-dev
* commit '92efd0c559d4d78880fc06544c662129fe7f6e1d':
Revert "Avoid size_t overflow in base64 decoding once again"
Diffstat (limited to 'media/libstagefright/foundation')
-rw-r--r-- | media/libstagefright/foundation/base64.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/media/libstagefright/foundation/base64.cpp b/media/libstagefright/foundation/base64.cpp index 7da7db9..dcf5bef 100644 --- a/media/libstagefright/foundation/base64.cpp +++ b/media/libstagefright/foundation/base64.cpp @@ -22,11 +22,11 @@ namespace android { sp<ABuffer> decodeBase64(const AString &s) { - size_t n = s.size(); - if ((n % 4) != 0) { + if ((s.size() % 4) != 0) { return NULL; } + size_t n = s.size(); size_t padding = 0; if (n >= 1 && s.c_str()[n - 1] == '=') { padding = 1; @@ -40,16 +40,11 @@ sp<ABuffer> decodeBase64(const AString &s) { } } - // We divide first to avoid overflow. It's OK to do this because we - // already made sure that n % 4 == 0. - size_t outLen = (n / 4) * 3 - padding; + size_t outLen = 3 * s.size() / 4 - padding; sp<ABuffer> buffer = new ABuffer(outLen); uint8_t *out = buffer->data(); - if (out == NULL || buffer->size() < outLen) { - return NULL; - } size_t j = 0; uint32_t accum = 0; for (size_t i = 0; i < n; ++i) { |