summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorEven Rouault <even.rouault@spatialys.com>2017-07-03 14:33:57 +0200
committerEven Rouault <even.rouault@spatialys.com>2017-07-03 14:33:57 +0200
commitc308de39edc1697efbd5c10dc4852a58f9b86558 (patch)
tree924c21388976f729eb446b4396d20b9c58ac79ca /src/lib
parent5736b1a3683261a5b31fc19a691731dc9fce5920 (diff)
opj_j2k_read_header_procedure(): validate marker size to avoid excessive memory allocation attempt
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/openjp2/j2k.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/lib/openjp2/j2k.c b/src/lib/openjp2/j2k.c
index 4c2b9326..f908c655 100644
--- a/src/lib/openjp2/j2k.c
+++ b/src/lib/openjp2/j2k.c
@@ -7711,6 +7711,10 @@ static OPJ_BOOL opj_j2k_read_header_procedure(opj_j2k_t *p_j2k,
/* read 2 bytes as the marker size */
opj_read_bytes(p_j2k->m_specific_param.m_decoder.m_header_data, &l_marker_size,
2);
+ if (l_marker_size < 2) {
+ opj_event_msg(p_manager, EVT_ERROR, "Invalid marker size\n");
+ return OPJ_FALSE;
+ }
l_marker_size -= 2; /* Subtract the size of the marker ID already read */
/* Check if the marker size is compatible with the header data size */