aboutsummaryrefslogtreecommitdiffstats
path: root/community/lcms
diff options
context:
space:
mode:
Diffstat (limited to 'community/lcms')
-rw-r--r--community/lcms/APKBUILD49
-rw-r--r--community/lcms/CVE-2013-4276.patch62
-rw-r--r--community/lcms/configure-for-musl.patch20
-rw-r--r--community/lcms/ppc64le.patch16
-rw-r--r--community/lcms/remove-linear-interpol-test.patch279
5 files changed, 426 insertions, 0 deletions
diff --git a/community/lcms/APKBUILD b/community/lcms/APKBUILD
new file mode 100644
index 0000000000..38612d2948
--- /dev/null
+++ b/community/lcms/APKBUILD
@@ -0,0 +1,49 @@
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=lcms
+pkgver=1.19
+pkgrel=8
+pkgdesc="Lightweight color management development library/engine"
+url="http://www.littlecms.com"
+arch="all"
+license="MIT"
+makedepends="tiff-dev libjpeg-turbo-dev zlib-dev"
+subpackages="$pkgname-dev $pkgname-doc liblcms"
+source="https://downloads.sourceforge.net/project/lcms/lcms/$pkgver/lcms-$pkgver.tar.gz
+ configure-for-musl.patch
+ CVE-2013-4276.patch
+ ppc64le.patch
+ remove-linear-interpol-test.patch
+ "
+
+prepare() {
+ update_config_sub
+ default_prepare
+}
+
+build() {
+ ./configure \
+ --build=$CBUILD \
+ --host=$CHOST \
+ --prefix=/usr
+ make
+}
+
+check() {
+ make check
+}
+
+package() {
+ make DESTDIR="$pkgdir" install
+ install -Dm 644 COPYING $pkgdir/usr/share/licenses/$pkgname/LICENSE
+}
+
+liblcms() {
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/liblcms.so.* "$subpkgdir"/usr/lib/
+}
+
+sha512sums="85a55ad0673f0df2aaa80d18caa50314319f8da5ee4d84eed919059d0dad9861d684ef6353ce0ec6f9892a4603ce8e8e12f84d46858e23f52846b8aefd3cf449 lcms-1.19.tar.gz
+5ef4671234cec59a8ba088937d6e4c26cfdadbe69ad2654eeb8521fd7c15f7405fc18f860722b41e2da9f55637325fe39e36c080003eed0371e6610d2e3fd264 configure-for-musl.patch
+73037e6e2f8e52f402c5160a38e1d8cc6f7f5f88145d68f733f796def539902a6dfcf685eae076d1456d885c782771993dc64f78b4e381421b0e4e8730eaa1d2 CVE-2013-4276.patch
+80eb01662357123fba965300111f1d0fb524d9ae58a54bf39c9563edb6407d7a95855906c2991af6de5aa4629624fdb35d4e6c274b1c990597961ff4ec3022a9 ppc64le.patch
+c7a43657b7e1f8e7402274ff5ac767e716b8a07cf44e7d089222568bdc75dcb830de2121a35db2040e52196386324b139f45ac9d014805086cf334a482efb39e remove-linear-interpol-test.patch"
diff --git a/community/lcms/CVE-2013-4276.patch b/community/lcms/CVE-2013-4276.patch
new file mode 100644
index 0000000000..8f2f322978
--- /dev/null
+++ b/community/lcms/CVE-2013-4276.patch
@@ -0,0 +1,62 @@
+diff -ur lcms-1.19.dfsg/samples/icctrans.c lcms-1.19.dfsg-patched/samples/icctrans.c
+--- lcms-1.19.dfsg/samples/icctrans.c 2009-10-30 15:57:45.000000000 +0000
++++ lcms-1.19.dfsg-patched/samples/icctrans.c 2013-08-06 11:53:14.385266647 +0100
+@@ -86,6 +86,8 @@
+ static LPcmsNAMEDCOLORLIST InputColorant = NULL;
+ static LPcmsNAMEDCOLORLIST OutputColorant = NULL;
+
++unsigned int Buffer_size = 4096;
++
+
+ // isatty replacement
+
+@@ -500,7 +502,7 @@
+
+ Prefix[0] = 0;
+ if (!lTerse)
+- sprintf(Prefix, "%s=", C);
++ snprintf(Prefix, 20, "%s=", C);
+
+ if (InHexa)
+ {
+@@ -648,7 +650,9 @@
+ static
+ void GetLine(char* Buffer)
+ {
+- scanf("%s", Buffer);
++ char User_buffer[Buffer_size];
++ fgets(User_buffer, (Buffer_size - 1), stdin);
++ sscanf(User_buffer,"%s", Buffer);
+
+ if (toupper(Buffer[0]) == 'Q') { // Quit?
+
+@@ -668,7 +672,7 @@
+ static
+ double GetAnswer(const char* Prompt, double Range)
+ {
+- char Buffer[4096];
++ char Buffer[Buffer_size];
+ double val = 0.0;
+
+ if (Range == 0.0) { // Range 0 means double value
+@@ -738,7 +742,7 @@
+ static
+ WORD GetIndex(void)
+ {
+- char Buffer[4096], Name[40], Prefix[40], Suffix[40];
++ char Buffer[Buffer_size], Name[40], Prefix[40], Suffix[40];
+ int index, max;
+
+ max = cmsNamedColorCount(hTrans)-1;
+diff -ur lcms-1.19.dfsg/tifficc/tiffdiff.c lcms-1.19.dfsg-patched/tifficc/tiffdiff.c
+--- lcms-1.19.dfsg/tifficc/tiffdiff.c 2009-10-30 15:57:46.000000000 +0000
++++ lcms-1.19.dfsg-patched/tifficc/tiffdiff.c 2013-08-06 11:49:06.698951157 +0100
+@@ -633,7 +633,7 @@
+ cmsIT8SetSheetType(hIT8, "TIFFDIFF");
+
+
+- sprintf(Buffer, "Differences between %s and %s", TiffName1, TiffName2);
++ snprintf(Buffer, 256, "Differences between %s and %s", TiffName1, TiffName2);
+
+ cmsIT8SetComment(hIT8, Buffer);
+
diff --git a/community/lcms/configure-for-musl.patch b/community/lcms/configure-for-musl.patch
new file mode 100644
index 0000000000..b9977dcbf6
--- /dev/null
+++ b/community/lcms/configure-for-musl.patch
@@ -0,0 +1,20 @@
+--- lcms-1.19/include/lcms.h.old 2009-10-30 10:57:45.000000000 -0500
++++ lcms-1.19/include/lcms.h 2017-09-08 00:47:09.931999949 -0500
+@@ -55,7 +55,7 @@
+
+ // Some machines does not have a reliable 'swab' function. Usually
+ // leave commented unless the testbed diagnoses the contrary.
+-// #define USE_CUSTOM_SWAB 1
++#define USE_CUSTOM_SWAB 1
+
+ // Uncomment this if your compiler supports inline
+ #define USE_INLINE 1
+@@ -64,7 +64,7 @@
+ // #define USE_DEFAULT_FLOOR_CONVERSION 1
+
+ // Uncomment this line on multithreading environments
+-// #define USE_PTHREADS 1
++#define USE_PTHREADS 1
+
+ // Uncomment this line if you want lcms to use the black point tag in profile,
+ // if commented, lcms will compute the black point by its own.
diff --git a/community/lcms/ppc64le.patch b/community/lcms/ppc64le.patch
new file mode 100644
index 0000000000..dfdfcec00d
--- /dev/null
+++ b/community/lcms/ppc64le.patch
@@ -0,0 +1,16 @@
+--- lcms-1.19.orig/include/lcms.h
++++ lcms-1.19/include/lcms.h
+@@ -139,12 +139,8 @@
+ # define USE_BIG_ENDIAN 1
+ #endif
+
+-#if defined(__sgi__) || defined(__sgi) || defined(__powerpc__) || defined(sparc) || defined(__ppc__) || defined(__s390__) || defined(__s390x__)
++#if defined(__sgi__) || defined(__sgi) || defined(sparc) || defined(__s390__) || defined(__s390x__)
+ # define USE_BIG_ENDIAN 1
+-#endif
+-
+-#if TARGET_CPU_PPC
+-# define USE_BIG_ENDIAN 1
+ #endif
+
+ #if macintosh
diff --git a/community/lcms/remove-linear-interpol-test.patch b/community/lcms/remove-linear-interpol-test.patch
new file mode 100644
index 0000000000..3e93e6946d
--- /dev/null
+++ b/community/lcms/remove-linear-interpol-test.patch
@@ -0,0 +1,279 @@
+diff --git a/testbed/testcms.c b/testbed/testcms.c
+index 98ec153..1f3f162 100755
+--- a/testbed/testcms.c
++++ b/testbed/testcms.c
+@@ -329,266 +329,6 @@ int TestReversingOfCurves(void)
+ // Tables are supposed to be monotonic, but the algorithm works on
+ // non-monotonic as well.
+
+-static
+-int TestLinearInterpolation(int lExhaustive)
+-{
+- static WORD Tab[4098];
+- int j, i, k = 0;
+- L16PARAMS p;
+- int n;
+- clock_t time;
+-
+- printf("Testing linear interpolation ...");
+-
+- // First I will check exact values. Since prime factors of 65535 (FFFF) are,
+- //
+- // 0xFFFF = 1 * 3 * 5 * 17 * 257
+- //
+- // I test tables of 2, 4, 6, and 18 points, that will be exact.
+- // Then, a table of 3 elements are tested. Error must be < 1
+- // Since no floating point is involved, This will be a measure of speed.
+-
+-
+- // Perform 10 times, so i can measure average times
+-
+- time = clock();
+- for (j=0; j < 10; j++)
+- {
+-
+- // 2 points - exact
+-
+- Tab[0] = 0;
+- Tab[1] = 0xffffU;
+-
+- cmsCalcL16Params(2, &p);
+-
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (n != i)
+- {
+- printf("Error in Linear interpolation (2p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+-
+- }
+-
+-
+- // 3 points - Here the error must be <= 1, since
+- // 2 == (3 - 1) is not a factor of 0xffff
+-
+- Tab[0] = 0;
+- Tab[1] = 0x7FFF;
+- Tab[2] = 0xffffU;
+-
+- cmsCalcL16Params(3, &p);
+-
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (abs(n - i) > 1)
+- {
+- printf("Error in Linear interpolation (3p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+-
+- }
+-
+-
+- // 4 points - exact
+-
+- Tab[0] = 0;
+- Tab[1] = 0x5555U;
+- Tab[2] = 0xAAAAU;
+- Tab[3] = 0xffffU;
+-
+- cmsCalcL16Params(4, &p);
+-
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (n != i) {
+- printf("Error in Linear interpolation (4p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+-
+- }
+-
+-
+- // 6 - points
+-
+- Tab[0] = 0;
+- Tab[1] = 0x3333U;
+- Tab[2] = 0x6666U;
+- Tab[3] = 0x9999U;
+- Tab[4] = 0xCCCCU;
+- Tab[5] = 0xFFFFU;
+-
+- cmsCalcL16Params(6, &p);
+-
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (n != i) {
+- printf("Error in Linear interpolation (6p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+-
+- }
+-
+-
+- // 18 points
+-
+- for (i=0; i < 18; i++)
+- Tab[i] = (WORD) (0x0f0fU*i);
+-
+- cmsCalcL16Params(18, &p);
+-
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (n != i) {
+- printf("Error in Linear interpolation (18p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+- }
+- }
+-
+-
+-
+- printf("pass. (%d tics)\n", (int) (clock() - time));
+-
+- // Now test descending tables
+- printf("Testing descending tables (linear interpolation)...");
+-
+- // 2 points - exact
+-
+- Tab[1] = 0;
+- Tab[0] = 0xffffU;
+-
+- cmsCalcL16Params(2, &p);
+-
+- for (i=0xffffL; i > 0; --i)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if ((0xffffL - n) != i) {
+-
+- printf("Error in Linear interpolation (descending) (2p): Must be i=%x, But is n=%x\n", i, 0xffff - n);
+- return 0;
+- }
+- }
+-
+-
+- // 3 points - Here the error must be <= 1, since
+- // 2 = (3 - 1) is not a factor of 0xffff
+-
+- Tab[2] = 0;
+- Tab[1] = 0x7FFF;
+- Tab[0] = 0xffffU;
+-
+- cmsCalcL16Params(3, &p);
+-
+- for (i=0xffffL; i > 0; --i)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (abs((0xffffL - n) - i) > 1) {
+-
+- printf("Error in Linear interpolation (descending) (3p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+- }
+-
+-
+- // 4 points - exact
+-
+- Tab[3] = 0;
+- Tab[2] = 0x5555U;
+- Tab[1] = 0xAAAAU;
+- Tab[0] = 0xffffU;
+-
+- cmsCalcL16Params(4, &p);
+-
+- for (i=0xffffL; i > 0; --i)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if ((0xffffL - n) != i) {
+-
+- printf("Error in Linear interpolation (descending) (4p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+- }
+-
+-
+- // 6 - points
+-
+- Tab[5] = 0;
+- Tab[4] = 0x3333U;
+- Tab[3] = 0x6666U;
+- Tab[2] = 0x9999U;
+- Tab[1] = 0xCCCCU;
+- Tab[0] = 0xFFFFU;
+-
+- cmsCalcL16Params(6, &p);
+-
+- for (i=0xffffL; i > 0; --i)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if ((0xffffL - n) != i) {
+- printf("Error in Linear interpolation (descending) (6p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+-
+- }
+-
+-
+- // 18 points
+-
+- for (i=0; i < 18; i++)
+- Tab[17-i] = (WORD) (0x0f0fU*i);
+-
+- cmsCalcL16Params(18, &p);
+-
+- for (i=0xffffL; i > 0; --i)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if ((0xffffL - n) != i) {
+-
+- printf("Error in Linear interpolation (descending) (18p): Must be i=%x, But is n=%x\n", i, n);
+- return 0;
+- }
+- }
+-
+- printf("pass.\n");
+-
+- if (!lExhaustive) return 1;
+-
+- printf("Now, testing interpolation errors for tables of n elements ...\n");
+-
+- for (j=10; j < 4096; j ++)
+- {
+- if ((j % 10) == 0) printf("%d\r", j);
+-
+- for (i=0; i <= j; i++)
+- {
+- Tab[i] = (WORD) floor((((double) i / ((double) j-1)) * 65535.0) + .5);
+- }
+-
+- k =0;
+- cmsCalcL16Params(j, &p);
+- for (i=0; i <= 0xffffL; i++)
+- {
+- n = cmsLinearInterpLUT16((WORD) i, Tab, &p);
+- if (n != i) k++;
+-
+- }
+-
+- }
+- printf("\n%d: %d errors\n\n", j, k);
+- return 1;
+-}
+-
+-
+-
+ static
+ int IsGood(const char *frm, WORD in, WORD out)
+ {
+@@ -2318,7 +2058,6 @@ int main(int argc, char *argv[])
+ if (!TestFixedScaling()) return 1;
+ if (!TestJointCurves()) return 1;
+ if (!TestReversingOfCurves()) return 1;
+- if (!TestLinearInterpolation(lExhaustive)) return 1;
+ if (!TestReverseLinearInterpolation()) return 1;
+
+