File openjpeg2-CVE-2018-16376.patch of Package openjpeg2.36921

Index: openjpeg-2.1.0/src/lib/openmj2/t2.c
===================================================================
--- openjpeg-2.1.0.orig/src/lib/openmj2/t2.c
+++ openjpeg-2.1.0/src/lib/openmj2/t2.c
@@ -151,6 +151,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;
@@ -254,6 +258,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;
openSUSE Build Service is sponsored by