Permalink
Browse files

Add bounds checks to jpeg parsing code.

Change: 140740851
  • Loading branch information...
saeta authored and tensorflower-gardener committed Dec 1, 2016
1 parent 30004dd commit 5e0c9fff657498f9a74da38b2ce1b4721698a388
Showing with 10 additions and 2 deletions.
  1. +10 −2 tensorflow/core/lib/jpeg/jpeg_handle.cc
@@ -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;
}
}
// -----------------------------------------------------------------------------

0 comments on commit 5e0c9ff

Please sign in to comment.