Skip to content

Commit

Permalink
validate filesize before allocating chunk memory (#1161)
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Hillman <peterh@wetafx.co.nz>
  • Loading branch information
peterhillman committed Sep 28, 2021
1 parent c2e7a37 commit 35b6908
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/lib/OpenEXRCore/chunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ extract_chunk_table (
return ctxt->report_error (
ctxt, EXR_ERR_INVALID_ARGUMENT, "Invalid file with no chunks");

if (chunkbytes + chunkoff > (uint64_t) ctxt->file_size)
return ctxt->print_error (
ctxt,
EXR_ERR_INVALID_ARGUMENT,
"chunk table size (%" PRIu64
") too big for file size (%" PRId64 ")",
chunkbytes,
ctxt->file_size);



ctable = (uint64_t*) ctxt->alloc_fn (chunkbytes);
if (ctable == NULL)
return ctxt->standard_error (ctxt, EXR_ERR_OUT_OF_MEMORY);
Expand Down

0 comments on commit 35b6908

Please sign in to comment.