Fixes intermittent crash in graphics/colord. Patch from upstream.
okay?
Repoduced and tested with the following loop:
cd /usr/obj/ports/colord-1.3.5/colord-1.3.5/data/profiles
while LD_LIBRARY_PATH=../../client/.libs/ ../../client/.libs/cd-create-profile
--output x11-colors.icc ./x11-colors.xml; do rm x11-colors.icc; done
Index: Makefile
===================================================================
RCS file: /cvs/ports/graphics/lcms2/Makefile,v
retrieving revision 1.16
diff -u -p -u -r1.16 Makefile
--- Makefile 12 Jul 2019 20:47:01 -0000 1.16
+++ Makefile 1 Oct 2019 17:51:06 -0000
@@ -3,6 +3,7 @@
COMMENT = color management library
DISTNAME = lcms2-2.9
+REVISION = 0
CATEGORIES = graphics
MASTER_SITES = ${MASTER_SITE_SOURCEFORGE:=lcms/}
Index: patches/patch-src_cmstypes_c
===================================================================
RCS file: patches/patch-src_cmstypes_c
diff -N patches/patch-src_cmstypes_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_cmstypes_c 1 Oct 2019 17:51:06 -0000
@@ -0,0 +1,138 @@
+$OpenBSD$
+
+fixed a out-of-bounds error on certain conditions
+https://github.com/mm2/Little-CMS/commit/9632a058a0c617a6461a1c32bc437fef87b3de9c
+
+Index: src/cmstypes.c
+--- src/cmstypes.c.orig
++++ src/cmstypes.c
+@@ -1853,7 +1853,7 @@ Error:
+ static
+ cmsBool Type_LUT8_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER*
io, void* Ptr, cmsUInt32Number nItems)
+ {
+- cmsUInt32Number j, nTabSize;
++ cmsUInt32Number j, nTabSize, i, n;
+ cmsUInt8Number val;
+ cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
+ cmsStage* mpe;
+@@ -1902,22 +1902,19 @@ cmsBool Type_LUT8_Write(struct _cms_typehandler_struc
+ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
+ if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
+
++ n = NewLUT->InputChannels * NewLUT->OutputChannels;
+
+ if (MatMPE != NULL) {
+
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
+-
++ for (i = 0; i < n; i++)
++ {
++ if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i]))
return FALSE;
++ }
+ }
+ else {
+
++ if (n != 9) return FALSE;
++
+ if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+@@ -2143,7 +2140,7 @@ Error:
+ static
+ cmsBool Type_LUT16_Write(struct _cms_typehandler_struct* self, cmsIOHANDLER*
io, void* Ptr, cmsUInt32Number nItems)
+ {
+- cmsUInt32Number nTabSize;
++ cmsUInt32Number nTabSize, n;
+ cmsPipeline* NewLUT = (cmsPipeline*) Ptr;
+ cmsStage* mpe;
+ _cmsStageToneCurvesData* PreMPE = NULL, *PostMPE = NULL;
+@@ -2194,21 +2191,20 @@ cmsBool Type_LUT16_Write(struct _cms_typehandler_stru
+ if (!_cmsWriteUInt8Number(io, (cmsUInt8Number) clutPoints)) return FALSE;
+ if (!_cmsWriteUInt8Number(io, 0)) return FALSE; // Padding
+
++ n = NewLUT->InputChannels * NewLUT->OutputChannels;
+
+ if (MatMPE != NULL) {
+
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[0])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[1])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[2])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[3])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[4])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[5])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[6])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[7])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, MatMPE -> Double[8])) return FALSE;
++ for (i = 0; i < n; i++)
++ {
++ if (!_cmsWrite15Fixed16Number(io, MatMPE->Double[i]))
return FALSE;
++ }
++
+ }
+ else {
+
++ if (n != 9) return FALSE;
++
+ if (!_cmsWrite15Fixed16Number(io, 1)) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+ if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+@@ -2550,31 +2546,31 @@ Error:
+ static
+ cmsBool WriteMatrix(struct _cms_typehandler_struct* self, cmsIOHANDLER* io,
cmsStage* mpe)
+ {
++ cmsUInt32Number i, n;
++
+ _cmsStageMatrixData* m = (_cmsStageMatrixData*) mpe -> Data;
+
+- // Write the Matrix
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[0])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[1])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[2])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[3])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[4])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[5])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[6])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[7])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Double[8])) return FALSE;
++ n = mpe->InputChannels * mpe->OutputChannels;
+
+- if (m ->Offset != NULL) {
++ // Write the Matrix
++ for (i = 0; i < n; i++)
++ {
++ if (!_cmsWrite15Fixed16Number(io, m->Double[i])) return FALSE;
++ }
+
+- if (!_cmsWrite15Fixed16Number(io, m -> Offset[0])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Offset[1])) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, m -> Offset[2])) return FALSE;
+- }
+- else {
+- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
+- if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
++ if (m->Offset != NULL) {
+
+- }
++ for (i = 0; i < mpe->OutputChannels; i++)
++ {
++ if (!_cmsWrite15Fixed16Number(io, m->Offset[i])) return
FALSE;
++ }
++ }
++ else {
++ for (i = 0; i < mpe->OutputChannels; i++)
++ {
++ if (!_cmsWrite15Fixed16Number(io, 0)) return FALSE;
++ }
++ }
+
+
+ return TRUE;