Merge pull request #1301 from rouault/fix_1299

opj_j2k_write_sod(): avoid potential heap buffer overflow (fixes #1299) (probably master only)
This commit is contained in:
Even Rouault 2020-12-02 23:56:57 +01:00 committed by GitHub
commit aaff099b49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -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,