Skip to content

Commit

Permalink
Add bounds checks to jpeg parsing code.
Browse files Browse the repository at this point in the history
Change: 140740851
  • Loading branch information
saeta authored and tensorflower-gardener committed Dec 1, 2016
1 parent 30004dd commit 5e0c9ff
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions tensorflow/core/lib/jpeg/jpeg_handle.cc
Expand Up @@ -147,8 +147,16 @@ void MemTermSource(j_decompress_ptr cinfo) {}
// -----------------------------------------------------------------------------
void MemSkipInputData(j_decompress_ptr cinfo, long jump) {
MemSourceMgr *src = reinterpret_cast<MemSourceMgr *>(cinfo->src);
src->pub.bytes_in_buffer -= jump;
src->pub.next_input_byte += jump;
if (jump < 0) {
return;
}
if (jump > src->pub.bytes_in_buffer) {
src->pub.bytes_in_buffer = 0;
(void)MemFillInputBuffer(cinfo); // warn with a fake EOI or error
} else {
src->pub.bytes_in_buffer -= jump;
src->pub.next_input_byte += jump;
}
}

// -----------------------------------------------------------------------------
Expand Down

0 comments on commit 5e0c9ff

Please sign in to comment.