X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fopenjp2%2Ft2.c;h=0fd5300c69b3649b9f31c21d0bf6f799bf45f39f;hb=c535531f03369623b9b833ef41952c62257b507e;hp=9d31acda81f7aad45fe3e2bba40464d9670eb0eb;hpb=dcac91b8c72f743bda7dbfa9032356bc8110098a;p=openjpeg.git diff --git a/src/lib/openjp2/t2.c b/src/lib/openjp2/t2.c index 9d31acda..0fd5300c 100644 --- a/src/lib/openjp2/t2.c +++ b/src/lib/openjp2/t2.c @@ -629,6 +629,15 @@ static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno, /* */ if (tcp->csty & J2K_CP_CSTY_SOP) { + if (length < 6) { + if (p_t2_mode == FINAL_PASS) { + opj_event_msg(p_manager, EVT_ERROR, + "opj_t2_encode_packet(): only %u bytes remaining in " + "output buffer. %u needed.\n", + length, 6); + } + return OPJ_FALSE; + } c[0] = 255; c[1] = 145; c[2] = 0; @@ -817,6 +826,15 @@ static OPJ_BOOL opj_t2_encode_packet(OPJ_UINT32 tileno, /* */ if (tcp->csty & J2K_CP_CSTY_EPH) { + if (length < 2) { + if (p_t2_mode == FINAL_PASS) { + opj_event_msg(p_manager, EVT_ERROR, + "opj_t2_encode_packet(): only %u bytes remaining in " + "output buffer. %u needed.\n", + length, 2); + } + return OPJ_FALSE; + } c[0] = 255; c[1] = 146; c += 2;