File openjpeg2-CVE-2020-27845.patch of Package openjpeg2.36921
Index: openjpeg-2.1.0/src/lib/openjp2/pi.c
===================================================================
--- openjpeg-2.1.0.orig/src/lib/openjp2/pi.c
+++ openjpeg-2.1.0/src/lib/openjp2/pi.c
@@ -235,6 +235,11 @@ OPJ_BOOL opj_pi_next_lrcp(opj_pi_iterato
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
+ if (pi->poc.compno0 >= pi->numcomps ||
+ pi->poc.compno1 >= pi->numcomps + 1) {
+ return OPJ_FALSE;
+ }
+
if (!pi->first) {
comp = &pi->comps[pi->compno];
res = &comp->resolutions[pi->resno];
@@ -278,6 +283,11 @@ OPJ_BOOL opj_pi_next_rlcp(opj_pi_iterato
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
+ if (pi->poc.compno0 >= pi->numcomps ||
+ pi->poc.compno1 >= pi->numcomps + 1) {
+ return OPJ_FALSE;
+ }
+
if (!pi->first) {
comp = &pi->comps[pi->compno];
res = &comp->resolutions[pi->resno];
@@ -320,6 +330,11 @@ OPJ_BOOL opj_pi_next_rpcl(opj_pi_iterato
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
+ if (pi->poc.compno0 >= pi->numcomps ||
+ pi->poc.compno1 >= pi->numcomps + 1) {
+ return OPJ_FALSE;
+ }
+
if (!pi->first) {
goto LABEL_SKIP;
} else {
@@ -410,6 +425,11 @@ OPJ_BOOL opj_pi_next_pcrl(opj_pi_iterato
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
+ if (pi->poc.compno0 >= pi->numcomps ||
+ pi->poc.compno1 >= pi->numcomps + 1) {
+ return OPJ_FALSE;
+ }
+
if (!pi->first) {
comp = &pi->comps[pi->compno];
goto LABEL_SKIP;
@@ -519,6 +539,11 @@ OPJ_BOOL opj_pi_next_cprl(opj_pi_iterato
opj_pi_resolution_t *res = NULL;
OPJ_UINT32 index = 0;
+ if (pi->poc.compno0 >= pi->numcomps ||
+ pi->poc.compno1 >= pi->numcomps + 1) {
+ return OPJ_FALSE;
+ }
+
if (!pi->first) {
comp = &pi->comps[pi->compno];
goto LABEL_SKIP;