Skip to content

Commit

Permalink
Fix integer overflow by checking size against header_size
Browse files Browse the repository at this point in the history
Note that the problem occurs when data_size is less than header_size
what causes a buffer overflow in &data[i]

Co-Authored-By: D4N <dan.cermak@cgc-instruments.com>
  • Loading branch information
piponazo and D4N committed Jul 15, 2019
1 parent a048325 commit e925bc5
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/webpimage.cpp
Expand Up @@ -827,8 +827,9 @@ namespace Exiv2 {
}
}

long WebPImage::getHeaderOffset(byte *data, long data_size,
byte *header, long header_size) {
long WebPImage::getHeaderOffset(byte* data, long data_size, byte* header, long header_size)
{
if (data_size < header_size) { return -1; }
long pos = -1;
for (long i=0; i < data_size - header_size; i++) {
if (memcmp(header, &data[i], header_size) == 0) {
Expand Down

0 comments on commit e925bc5

Please sign in to comment.