diff options
author | Wonsik Kim <wonsik@google.com> | 2015-09-16 22:48:31 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-09-16 22:48:31 +0000 |
commit | 3c4216e5c76727f4af229e8b2a338e15f67e1ee9 (patch) | |
tree | 7cf1a117a81c31f952a07f03b186abf1107a4f88 /media/libstagefright/foundation | |
parent | fd92e4d3e9648c520dc289f951dc7527a0424f38 (diff) | |
parent | 2fa6a5ad06e696627b0ca495a031531ac47ddd6d (diff) | |
download | frameworks_av-3c4216e5c76727f4af229e8b2a338e15f67e1ee9.zip frameworks_av-3c4216e5c76727f4af229e8b2a338e15f67e1ee9.tar.gz frameworks_av-3c4216e5c76727f4af229e8b2a338e15f67e1ee9.tar.bz2 |
am 2fa6a5ad: am 4d27a468: am 92efd0c5: am b5611b84: Merge "Revert "Avoid size_t overflow in base64 decoding once again"" into lmp-dev
* commit '2fa6a5ad06e696627b0ca495a031531ac47ddd6d':
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) { |