File openjpeg2-CVE-2018-16376.patch of Package openjpeg2.34968
Index: openjpeg-2.3.0/src/lib/openmj2/t2.c
===================================================================
--- openjpeg-2.3.0.orig/src/lib/openmj2/t2.c
+++ openjpeg-2.3.0/src/lib/openmj2/t2.c
@@ -166,6 +166,10 @@ static int t2_encode_packet(opj_tcd_tile
/* <SOP 0xff91> */
if (tcp->csty & J2K_CP_CSTY_SOP) {
+ if (length < 6) {
+ return OPJ_FALSE;
+ }
+
c[0] = 255;
c[1] = 145;
c[2] = 0;
@@ -272,6 +276,10 @@ static int t2_encode_packet(opj_tcd_tile
/* <EPH 0xff92> */
if (tcp->csty & J2K_CP_CSTY_EPH) {
+ if (length < 2) {
+ return OPJ_FALSE;
+ }
+
c[0] = 255;
c[1] = 146;
c += 2;