summaryrefslogtreecommitdiff
path: root/src/lib/openjp2/jp2.c
diff options
context:
space:
mode:
authorAntonin Descampe <antonin@descampe.net>2017-08-08 16:51:54 -0700
committerGitHub <noreply@github.com>2017-08-08 16:51:54 -0700
commit0394f8d0f1c981e0bc587beddc14d1fb0b265b1b (patch)
tree568c654ba7aaa5a6872875d4c61ec02b459e7497 /src/lib/openjp2/jp2.c
parent3b1b0672663b59853b63d48f94b63ca497883527 (diff)
parentbc3cb7410023e9d0c7ff9972a0bc8cf1fe9b32a4 (diff)
Merge pull request #975 from szukw000/changes-for-afl-tests
Catch images broken by AFL
Diffstat (limited to 'src/lib/openjp2/jp2.c')
-rw-r--r--src/lib/openjp2/jp2.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/openjp2/jp2.c b/src/lib/openjp2/jp2.c
index 33a10d30..df35a164 100644
--- a/src/lib/openjp2/jp2.c
+++ b/src/lib/openjp2/jp2.c
@@ -619,6 +619,11 @@ static OPJ_BOOL opj_jp2_read_ihdr(opj_jp2_t *jp2,
opj_read_bytes(p_image_header_data, &(jp2->IPR), 1); /* IPR */
++ p_image_header_data;
+ jp2->j2k->m_cp.bpc_is_255 = (jp2->bpc == 255);
+ jp2->j2k->ihdr_w = jp2->w;
+ jp2->j2k->ihdr_h = jp2->h;
+ jp2->has_ihdr = 1;
+
return OPJ_TRUE;
}
@@ -1573,6 +1578,9 @@ static OPJ_BOOL opj_jp2_read_colr(opj_jp2_t *jp2,
"COLR BOX meth value is not a regular value (%d), "
"so we will ignore the entire Colour Specification box. \n", jp2->meth);
}
+ if (jp2->color.jp2_has_colr) {
+ jp2->j2k->enumcs = jp2->enumcs;
+ }
return OPJ_TRUE;
}
@@ -2733,6 +2741,7 @@ static OPJ_BOOL opj_jp2_read_jp2h(opj_jp2_t *jp2,
}
jp2->jp2_state |= JP2_STATE_HEADER;
+ jp2->has_jp2h = 1;
return OPJ_TRUE;
}
@@ -2838,6 +2847,14 @@ OPJ_BOOL opj_jp2_read_header(opj_stream_private_t *p_stream,
if (! opj_jp2_exec(jp2, jp2->m_procedure_list, p_stream, p_manager)) {
return OPJ_FALSE;
}
+ if (jp2->has_jp2h == 0) {
+ opj_event_msg(p_manager, EVT_ERROR, "JP2H box missing. Required.\n");
+ return OPJ_FALSE;
+ }
+ if (jp2->has_ihdr == 0) {
+ opj_event_msg(p_manager, EVT_ERROR, "IHDR box_missing. Required.\n");
+ return OPJ_FALSE;
+ }
return opj_j2k_read_header(p_stream,
jp2->j2k,