diff options
author | Wei Jia <wjia@google.com> | 2015-08-12 10:41:00 -0700 |
---|---|---|
committer | Wei Jia <wjia@google.com> | 2015-08-12 18:51:25 +0000 |
commit | f51115bd8e44c2779b74477277c6f6046916e7cf (patch) | |
tree | a178d186a3a2c95529c24ddc35f02307a8c0d7e3 /media/libstagefright/id3/ID3.cpp | |
parent | c86eae32ebb0cc580a13dde30fe765a96b8e701c (diff) | |
download | frameworks_av-f51115bd8e44c2779b74477277c6f6046916e7cf.zip frameworks_av-f51115bd8e44c2779b74477277c6f6046916e7cf.tar.gz frameworks_av-f51115bd8e44c2779b74477277c6f6046916e7cf.tar.bz2 |
libstagefright: fix possible overflow in ID3.
Bug: 23129786
Change-Id: I2e6b7a6927aa4362ab49dd6824bbb1abf7b4e661
(cherry picked from commit 09da86913ca97d7a818a8917b6601527e5e18a24)
Diffstat (limited to 'media/libstagefright/id3/ID3.cpp')
-rw-r--r-- | media/libstagefright/id3/ID3.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp index 7f478f7..d34f1a7 100644 --- a/media/libstagefright/id3/ID3.cpp +++ b/media/libstagefright/id3/ID3.cpp @@ -327,7 +327,7 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) { size_t oldSize = mSize; size_t offset = 0; - while (offset + 10 <= mSize) { + while (mSize >= 10 && offset <= mSize - 10) { if (!memcmp(&mData[offset], "\0\0\0\0", 4)) { break; } @@ -339,7 +339,7 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) { return false; } - if (offset + dataSize + 10 > mSize) { + if (dataSize > mSize - 10 - offset) { return false; } @@ -349,6 +349,9 @@ bool ID3::removeUnsynchronizationV2_4(bool iTunesHack) { if (flags & 1) { // Strip data length indicator + if (mSize < 14 || mSize - 14 < offset) { + return false; + } memmove(&mData[offset + 10], &mData[offset + 14], mSize - offset - 14); mSize -= 4; dataSize -= 4; |