diff options
author | Marco Nelissen <marcone@google.com> | 2015-07-29 16:15:55 -0700 |
---|---|---|
committer | Marco Nelissen <marcone@google.com> | 2015-07-29 16:15:55 -0700 |
commit | 7d681539b821664d0417f8dd6beaed3352b34787 (patch) | |
tree | 3f4c4a8e6a574a3cb1675beaca223708e066afd0 /media/libstagefright/matroska | |
parent | a7d36c184562cc15b2d665ff25c485fefdcfbabd (diff) | |
download | frameworks_av-7d681539b821664d0417f8dd6beaed3352b34787.zip frameworks_av-7d681539b821664d0417f8dd6beaed3352b34787.tar.gz frameworks_av-7d681539b821664d0417f8dd6beaed3352b34787.tar.bz2 |
Guard against codecinfo overflow
Bug: 21296336
Change-Id: I78be5141b3108142f12d7cb94839fa50f776d84a
Diffstat (limited to 'media/libstagefright/matroska')
-rw-r--r-- | media/libstagefright/matroska/MatroskaExtractor.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/media/libstagefright/matroska/MatroskaExtractor.cpp b/media/libstagefright/matroska/MatroskaExtractor.cpp index e8bd432..ecc2573 100644 --- a/media/libstagefright/matroska/MatroskaExtractor.cpp +++ b/media/libstagefright/matroska/MatroskaExtractor.cpp @@ -871,25 +871,38 @@ status_t addVorbisCodecInfo( size_t offset = 1; size_t len1 = 0; while (offset < codecPrivateSize && codecPrivate[offset] == 0xff) { + if (len1 > (SIZE_MAX - 0xff)) { + return ERROR_MALFORMED; // would overflow + } len1 += 0xff; ++offset; } if (offset >= codecPrivateSize) { return ERROR_MALFORMED; } + if (len1 > (SIZE_MAX - codecPrivate[offset])) { + return ERROR_MALFORMED; // would overflow + } len1 += codecPrivate[offset++]; size_t len2 = 0; while (offset < codecPrivateSize && codecPrivate[offset] == 0xff) { + if (len2 > (SIZE_MAX - 0xff)) { + return ERROR_MALFORMED; // would overflow + } len2 += 0xff; ++offset; } if (offset >= codecPrivateSize) { return ERROR_MALFORMED; } + if (len2 > (SIZE_MAX - codecPrivate[offset])) { + return ERROR_MALFORMED; // would overflow + } len2 += codecPrivate[offset++]; - if (codecPrivateSize < offset + len1 + len2) { + if (len1 > SIZE_MAX - len2 || offset > SIZE_MAX - (len1 + len2) || + codecPrivateSize < offset + len1 + len2) { return ERROR_MALFORMED; } |