Skip to content

Commit

Permalink
Merge pull request #1295 from rouault/fix_1293
Browse files Browse the repository at this point in the history
opj_j2k_setup_encoder(): validate POC compno0 and compno1 (fixes #1293)
  • Loading branch information
rouault authored Dec 2, 2020
2 parents 630b485 + c9380ed commit 18b1138
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/openjp2/j2k.c
Original file line number Diff line number Diff line change
Expand Up @@ -7945,11 +7945,18 @@ OPJ_BOOL opj_j2k_setup_encoder(opj_j2k_t *p_j2k,
if (tileno + 1 == parameters->POC[i].tile) {
opj_poc_t *tcp_poc = &tcp->pocs[numpocs_tile];

if (parameters->POC[numpocs_tile].compno0 >= image->numcomps) {
opj_event_msg(p_manager, EVT_ERROR,
"Invalid compno0 for POC %d\n", i);
return OPJ_FALSE;
}

tcp_poc->resno0 = parameters->POC[numpocs_tile].resno0;
tcp_poc->compno0 = parameters->POC[numpocs_tile].compno0;
tcp_poc->layno1 = parameters->POC[numpocs_tile].layno1;
tcp_poc->resno1 = parameters->POC[numpocs_tile].resno1;
tcp_poc->compno1 = parameters->POC[numpocs_tile].compno1;
tcp_poc->compno1 = opj_uint_min(parameters->POC[numpocs_tile].compno1,
image->numcomps);
tcp_poc->prg1 = parameters->POC[numpocs_tile].prg1;
tcp_poc->tile = parameters->POC[numpocs_tile].tile;

Expand Down

0 comments on commit 18b1138

Please sign in to comment.