diff options
author | Wei Jia <wjia@google.com> | 2015-10-06 22:28:01 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-06 22:28:01 +0000 |
commit | 8b713f11afc2cd5bf4252022c84bb480a8dd492b (patch) | |
tree | 22583fb4e663edf754c0283954fb08e3adbf8afe | |
parent | f2cf2bd7448734c6881e3bea2b758f2bf9feeed9 (diff) | |
parent | b75a78db916a7becf7e1b5ad15c0b4e667ef4661 (diff) | |
download | frameworks_av-8b713f11afc2cd5bf4252022c84bb480a8dd492b.zip frameworks_av-8b713f11afc2cd5bf4252022c84bb480a8dd492b.tar.gz frameworks_av-8b713f11afc2cd5bf4252022c84bb480a8dd492b.tar.bz2 |
am b75a78db: am fc0e2a87: am 7ed8d1ef: ID3: check possible integer overflow for extendedHeaderSize and paddingSize.
* commit 'b75a78db916a7becf7e1b5ad15c0b4e667ef4661':
ID3: check possible integer overflow for extendedHeaderSize and paddingSize.
-rw-r--r-- | media/libstagefright/id3/ID3.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp index 683c6ef..ed2d941 100644 --- a/media/libstagefright/id3/ID3.cpp +++ b/media/libstagefright/id3/ID3.cpp @@ -194,6 +194,13 @@ struct id3_header { if (header.version_major == 4) { void *copy = malloc(size); + if (copy == NULL) { + free(mData); + mData = NULL; + ALOGE("b/24623447, no more memory"); + return false; + } + memcpy(copy, mData, size); bool success = removeUnsynchronizationV2_4(false /* iTunesHack */); @@ -234,7 +241,14 @@ struct id3_header { return false; } - size_t extendedHeaderSize = U32_AT(&mData[0]) + 4; + size_t extendedHeaderSize = U32_AT(&mData[0]); + if (extendedHeaderSize > SIZE_MAX - 4) { + free(mData); + mData = NULL; + ALOGE("b/24623447, extendedHeaderSize is too large"); + return false; + } + extendedHeaderSize += 4; if (extendedHeaderSize > mSize) { free(mData); @@ -252,7 +266,10 @@ struct id3_header { if (extendedHeaderSize >= 10) { size_t paddingSize = U32_AT(&mData[6]); - if (mFirstFrameOffset + paddingSize > mSize) { + if (paddingSize > SIZE_MAX - mFirstFrameOffset) { + ALOGE("b/24623447, paddingSize is too large"); + } + if (paddingSize > mSize - mFirstFrameOffset) { free(mData); mData = NULL; |