Skip to content

Commit

Permalink
Merge pull request #1301 from rouault/fix_1299
Browse files Browse the repository at this point in the history
opj_j2k_write_sod(): avoid potential heap buffer overflow (fixes #1299) (probably master only)
  • Loading branch information
rouault committed Dec 2, 2020
2 parents fb9eae5 + 73fdf28 commit aaff099
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/openjp2/j2k.c
Expand Up @@ -4806,8 +4806,13 @@ static OPJ_BOOL opj_j2k_write_sod(opj_j2k_t *p_j2k,
}
}

assert(l_remaining_data >
p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT);
if (l_remaining_data <
p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT) {
opj_event_msg(p_manager, EVT_ERROR,
"Not enough bytes in output buffer to write SOD marker\n");
opj_tcd_marker_info_destroy(marker_info);
return OPJ_FALSE;
}
l_remaining_data -= p_j2k->m_specific_param.m_encoder.m_reserved_bytes_for_PLT;

if (! opj_tcd_encode_tile(p_tile_coder, p_j2k->m_current_tile_number,
Expand Down

0 comments on commit aaff099

Please sign in to comment.