Skip to content

Commit

Permalink
Add extra checks to avoid integer overflow.
Browse files Browse the repository at this point in the history
BUG=425980
TEST=no crash with ASAN

Review URL: https://codereview.chromium.org/659743004

Cr-Commit-Position: refs/heads/master@{#301249}
  • Loading branch information
jrummell-chromium authored and Commit bot committed Oct 25, 2014
1 parent 55aa718 commit b2006ac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions media/base/container_names.cc
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ static bool CheckMov(const uint8* buffer, int buffer_size) {

int offset = 0;
while (offset + 8 < buffer_size) {
int atomsize = Read32(buffer + offset);
uint32 atomsize = Read32(buffer + offset);
uint32 atomtype = Read32(buffer + offset + 4);
// Only need to check for ones that are valid at the top level.
switch (atomtype) {
Expand Down Expand Up @@ -985,7 +985,7 @@ static bool CheckMov(const uint8* buffer, int buffer_size) {
break; // Offset is way past buffer size.
atomsize = Read32(buffer + offset + 12);
}
if (atomsize <= 0)
if (atomsize == 0 || atomsize > static_cast<size_t>(buffer_size))
break; // Indicates the last atom or length too big.
offset += atomsize;
}
Expand Down

0 comments on commit b2006ac

Please sign in to comment.