From b4d9e1b41301b11bf4e4d7c9cfef27850e518b0c Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Tue, 27 Jun 2017 13:58:07 -0700 Subject: [PATCH] stagefright: avoid buffer overflow in base64 decoder Bug: 62673128 Change-Id: Id5f04b772aaca3184879bd5bca453ad9e82c7f94 --- media/libstagefright/foundation/base64.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/media/libstagefright/foundation/base64.cpp b/media/libstagefright/foundation/base64.cpp index 95819864ba..31fae4efa6 100644 --- a/media/libstagefright/foundation/base64.cpp +++ b/media/libstagefright/foundation/base64.cpp @@ -74,8 +74,7 @@ sp decodeBase64(const AString &s) { accum = (accum << 6) | value; if (((i + 1) % 4) == 0) { - out[j++] = (accum >> 16); - + if (j < outLen) { out[j++] = (accum >> 16); } if (j < outLen) { out[j++] = (accum >> 8) & 0xff; } if (j < outLen) { out[j++] = accum & 0xff; } -- 2.11.0