Skip to content

Commit

Permalink
Fix write heap buffer overflow in opj_mqc_byteout(). Discovered by Ke…
Browse files Browse the repository at this point in the history
… Liu of Tencent's Xuanwu LAB (#835)
  • Loading branch information
rouault committed Jul 29, 2017
1 parent 11445ed commit 397f62c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/lib/openjp2/tcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,9 @@ static OPJ_BOOL opj_tcd_code_block_enc_allocate_data(opj_tcd_cblk_enc_t *
{
OPJ_UINT32 l_data_size;

l_data_size = (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) *
(p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32));
/* The +1 is needed for https://github.com/uclouvain/openjpeg/issues/835 */
l_data_size = 1 + (OPJ_UINT32)((p_code_block->x1 - p_code_block->x0) *
(p_code_block->y1 - p_code_block->y0) * (OPJ_INT32)sizeof(OPJ_UINT32));

if (l_data_size > p_code_block->data_size) {
if (p_code_block->data) {
Expand Down

0 comments on commit 397f62c

Please sign in to comment.