File openjpeg2-require-eph-when-specified.patch of Package openjpeg2.42421

Index: openjpeg-2.1.0/src/lib/openjp2/t2.c
===================================================================
--- openjpeg-2.1.0.orig/src/lib/openjp2/t2.c
+++ openjpeg-2.1.0/src/lib/openjp2/t2.c
@@ -887,6 +887,7 @@ OPJ_BOOL opj_t2_read_packet_header( opj_
         /* SOP markers */
 
         if (p_tcp->csty & J2K_CP_CSTY_SOP) {
+                /* SOP markers are allowed (i.e. optional), just warn */
                 if (p_max_length < 6) {
                         /* TODO opj_event_msg(p_t2->cinfo->event_mgr, EVT_WARNING, "Not enough space for expected SOP marker\n"); */
                         printf("Not enough space for expected SOP marker\n");
@@ -944,9 +945,11 @@ OPJ_BOOL opj_t2_read_packet_header( opj_
                 /* EPH markers */
                 if (p_tcp->csty & J2K_CP_CSTY_EPH) {
                         if (p_max_length < 2) {
-                                fprintf(stderr, "Not enough space for expected EPH marker\n");
+                                fprintf(stderr, "Not enough space for required EPH marker\n");
+                                return OPJ_FALSE;
                         } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
-                                fprintf(stderr, "Error : expected EPH marker\n");
+                                fprintf(stderr, "Error : required EPH marker\n");
+                                return OPJ_FALSE;
                         } else {
                                 l_header_data += 2;
                         }
@@ -1072,10 +1075,12 @@ OPJ_BOOL opj_t2_read_packet_header( opj_
         /* EPH markers */
         if (p_tcp->csty & J2K_CP_CSTY_EPH) {
                 if (p_max_length < 2) {
-                        fprintf(stderr, "Not enough space for expected EPH marker\n");
+                        fprintf(stderr, "Not enough space for required EPH marker\n");
+                        return OPJ_FALSE;
                 } else if ((*l_header_data) != 0xff || (*(l_header_data + 1) != 0x92)) {
                         /* TODO opj_event_msg(t2->cinfo->event_mgr, EVT_ERROR, "Expected EPH marker\n"); */
-                        fprintf(stderr, "Error : expected EPH marker\n");
+                        fprintf(stderr, "Error : required EPH marker\n");
+                        return OPJ_FALSE;
                 } else {
                         l_header_data += 2;
                 }
openSUSE Build Service is sponsored by