[Libreoffice-commits] core.git: external/libtiff

2023-08-20 Thread Caolán McNamara (via logerrit)
 
external/libtiff/0001-WebP-decoder-validate-WebP-blob-width-height-band-co.patch
 |   79 ++
 external/libtiff/UnpackedTarball_libtiff.mk
  |1 
 2 files changed, 80 insertions(+)

New commits:
commit e60ef8651cfb30335471d1622e58c13eebc7d58b
Author: Caolán McNamara 
AuthorDate: Sun Aug 20 20:37:26 2023 +0100
Commit: Caolán McNamara 
CommitDate: Sun Aug 20 22:48:13 2023 +0200

ofz: Use-of-uninitialized-value

same as seen at: https://gitlab.com/libtiff/libtiff/-/issues/582

Change-Id: Ifc4eaaa47ad392968db814783281f1db76564d9e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155874
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git 
a/external/libtiff/0001-WebP-decoder-validate-WebP-blob-width-height-band-co.patch
 
b/external/libtiff/0001-WebP-decoder-validate-WebP-blob-width-height-band-co.patch
new file mode 100644
index ..68353bd9ed20
--- /dev/null
+++ 
b/external/libtiff/0001-WebP-decoder-validate-WebP-blob-width-height-band-co.patch
@@ -0,0 +1,79 @@
+From 350ff161c8a61b6483a1e4689e09cd47dd0dd5f9 Mon Sep 17 00:00:00 2001
+From: Even Rouault 
+Date: Sat, 17 Jun 2023 16:22:38 +0200
+Subject: [PATCH] WebP decoder: validate WebP blob width, height, band count
+ against TIFF parameters
+
+to avoid use of uninitialized variable, or decoding corrupted content
+without explicit error
+
+Fixes #581, fixes #582
+---
+ libtiff/tif_webp.c | 51 ++
+ 1 file changed, 51 insertions(+)
+
+diff --git a/libtiff/tif_webp.c b/libtiff/tif_webp.c
+index 07db7cce..ce15391e 100644
+--- a/libtiff/tif_webp.c
 b/libtiff/tif_webp.c
+@@ -149,6 +149,57 @@ static int TWebPDecode(TIFF *tif, uint8_t *op, tmsize_t 
occ, uint16_t s)
+ segment_height = td->td_rowsperstrip;
+ }
+ 
++int webp_width, webp_height;
++if (!WebPGetInfo(tif->tif_rawcp,
++ tif->tif_rawcc > UINT32_MAX ? UINT32_MAX
++ : 
(uint32_t)tif->tif_rawcc,
++ _width, _height))
++{
++TIFFErrorExtR(tif, module, "WebPGetInfo() failed");
++return 0;
++}
++if ((uint32_t)webp_width != segment_width ||
++(uint32_t)webp_height != segment_height)
++{
++TIFFErrorExtR(
++tif, module, "WebP blob dimension is %dx%d. Expected %ux%u",
++webp_width, webp_height, segment_width, segment_height);
++return 0;
++}
++
++#if WEBP_DECODER_ABI_VERSION >= 0x0002
++WebPDecoderConfig config;
++if (!WebPInitDecoderConfig())
++{
++TIFFErrorExtR(tif, module, "WebPInitDecoderConfig() failed");
++return 0;
++}
++
++const bool bWebPGetFeaturesOK =
++WebPGetFeatures(tif->tif_rawcp,
++tif->tif_rawcc > UINT32_MAX
++? UINT32_MAX
++: (uint32_t)tif->tif_rawcc,
++) == VP8_STATUS_OK;
++
++WebPFreeDecBuffer();
++
++if (!bWebPGetFeaturesOK)
++{
++TIFFErrorExtR(tif, module, "WebPInitDecoderConfig() failed");
++return 0;
++}
++
++const int webp_bands = config.input.has_alpha ? 4 : 3;
++if (webp_bands != sp->nSamples)
++{
++TIFFErrorExtR(tif, module,
++  "WebP blob band count is %d. Expected %d", 
webp_bands,
++  sp->nSamples);
++return 0;
++}
++#endif
++
+ buffer_size = segment_width * segment_height * sp->nSamples;
+ if (occ == (tmsize_t)buffer_size)
+ {
+-- 
+2.41.0
+
diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index f7eeb6ace868..32ed699b7491 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,1))
 $(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
 external/libtiff/libtiff.linknolibs.patch \
 external/libtiff/0001-ofz-54685-Timeout.patch \
+
external/libtiff/0001-WebP-decoder-validate-WebP-blob-width-height-band-co.patch
 \
 ))
 
 # vim: set noet sw=4 ts=4:


[Libreoffice-commits] core.git: external/libtiff

2023-08-15 Thread Caolán McNamara (via logerrit)
 external/libtiff/ExternalProject_libtiff.mk |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 72b118e4cb7f97cbd296fd829a463fe9fafb8486
Author: Caolán McNamara 
AuthorDate: Mon Aug 14 15:41:49 2023 +0100
Commit: Caolán McNamara 
CommitDate: Tue Aug 15 11:51:45 2023 +0200

set libtiff ac_cv_lib_jpeg_jpeg12_read_scanlines cache val to false

to avoid:

...
checking for jpeg12_read_scanlines in -ljpeg... yes
...
JPEG 8/12 bit dual mode:yes (libjpeg turbo >= 2.2 dual mode)
...
tif_jpeg.c:143:25: error: unknown type name ‘J12SAMPARRAY’
  143 | #define TIFF_JSAMPARRAY J12SAMPARRAY

where the system jpeg is linked against during configure but the build
is against the internal jpeg and the system one happens to support
jpeg12_read_scanlines

Change-Id: I895d77c59a5bef1af0b1a85d44da1a54e502f8e4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155670
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/ExternalProject_libtiff.mk 
b/external/libtiff/ExternalProject_libtiff.mk
index e318126dcfe0..f6bcba106669 100644
--- a/external/libtiff/ExternalProject_libtiff.mk
+++ b/external/libtiff/ExternalProject_libtiff.mk
@@ -23,9 +23,10 @@ $(eval $(call gb_ExternalProject_use_autoconf,libtiff,build))
 
 # using ac_cv_lib_z_inflateEnd=yes to skip test for our
 # static windows lib where the name is zlib not z
-# using ac_cv_lib_jpeg_jpeg_read_scanlines to skip test
-# for our static windows lib where the name is libjpeg-turbo.lib
-# not libjpeg.lib
+# using ac_cv_lib_jpeg_jpeg_read_scanlines and
+# ac_cv_lib_jpeg_jpeg12_read_scanlines to skip tests
+# for our static jpeg lib where the name is libjpeg-turbo.lib
+# or liblibjpeg-turbo.a not libjpeg.lib/libjpeg.a
 # we're building this statically anyway so the lib isn't
 # used during the link done here
 
@@ -63,6 +64,7 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
LDFLAGS="$(call 
gb_ExternalProject_get_link_flags,libtiff) $(gb_EMSCRIPTEN_LDFLAGS)" \
ac_cv_lib_z_inflateEnd=yes \
ac_cv_lib_jpeg_jpeg_read_scanlines=yes \
+   ac_cv_lib_jpeg_jpeg12_read_scanlines=no \
ac_cv_lib_webp_WebPDecode=yes \
$(gb_CONFIGURE_PLATFORMS) \
&& cd libtiff && $(MAKE) libtiff.la \


[Libreoffice-commits] core.git: external/libtiff vcl/source

2023-01-20 Thread Caolán McNamara (via logerrit)
 external/libtiff/0001-ofz-54685-Timeout.patch |   59 ++
 external/libtiff/UnpackedTarball_libtiff.mk   |3 -
 external/libtiff/libtiff.linknolibs.patch |4 -
 vcl/source/filter/jpeg/jpegc.cxx  |1 
 4 files changed, 64 insertions(+), 3 deletions(-)

New commits:
commit 20b64cf1512572b7a57aa78920c025ff05a36964
Author: Caolán McNamara 
AuthorDate: Fri Jan 20 10:45:21 2023 +
Commit: Caolán McNamara 
CommitDate: Fri Jan 20 12:32:14 2023 +

ofz#54685 Timeout

Change-Id: I2f71f61c371055521c884a00dde48a811d204df1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145875
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/0001-ofz-54685-Timeout.patch 
b/external/libtiff/0001-ofz-54685-Timeout.patch
new file mode 100644
index ..e09b9679f083
--- /dev/null
+++ b/external/libtiff/0001-ofz-54685-Timeout.patch
@@ -0,0 +1,59 @@
+From caab95ab518aafbc985974098ad806f769c462ea Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= 
+Date: Fri, 20 Jan 2023 10:41:34 +
+Subject: [PATCH] ofz#54685 Timeout
+
+---
+ libtiff/tif_ojpeg.c | 29 +
+ 1 file changed, 29 insertions(+)
+
+diff --git a/libtiff/tif_ojpeg.c b/libtiff/tif_ojpeg.c
+index 0c915de2..27b84611 100644
+--- a/libtiff/tif_ojpeg.c
 b/libtiff/tif_ojpeg.c
+@@ -1312,6 +1312,34 @@ static int OJPEGReadSecondarySos(TIFF *tif, uint16_t s)
+ return (1);
+ }
+ 
++// see also vcl/source/filter/jpeg/jpegc.cxx
++static void emitMessage(j_common_ptr cinfo, int msg_level)
++{
++if (msg_level < 0)
++{
++// 
https://libjpeg-turbo.org/pmwiki/uploads/About/TwoIssueswiththeJPEGStandard.pdf
++// try to retain some degree of recoverability up to some reasonable
++// limit (initially using ImageMagick's current limit of 1000), then
++// bail.
++const int WarningLimit = 1000;
++#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
++// ofz#50452 due to Timeouts, just abandon fuzzing on any
++// JWRN_NOT_SEQUENTIAL
++if (cinfo->err->msg_code == JWRN_NOT_SEQUENTIAL)
++{
++cinfo->err->error_exit(cinfo);
++return;
++}
++#endif
++if (++cinfo->err->num_warnings > WarningLimit)
++cinfo->err->error_exit(cinfo);
++else
++cinfo->err->output_message(cinfo);
++}
++else if (cinfo->err->trace_level >= msg_level)
++cinfo->err->output_message(cinfo);
++}
++
+ static int OJPEGWriteHeaderInfo(TIFF *tif)
+ {
+ static const char module[] = "OJPEGWriteHeaderInfo";
+@@ -1327,6 +1355,7 @@ static int OJPEGWriteHeaderInfo(TIFF *tif)
+ sp->libjpeg_jpeg_error_mgr.output_message =
+ OJPEGLibjpegJpegErrorMgrOutputMessage;
+ sp->libjpeg_jpeg_error_mgr.error_exit = OJPEGLibjpegJpegErrorMgrErrorExit;
++sp->libjpeg_jpeg_error_mgr.emit_message = emitMessage;
+ sp->libjpeg_jpeg_decompress_struct.err = &(sp->libjpeg_jpeg_error_mgr);
+ sp->libjpeg_jpeg_decompress_struct.client_data = (void *)tif;
+ if (jpeg_create_decompress_encap(
+-- 
+2.39.0
+
diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index ce5a3a53d36a..f7eeb6ace868 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -11,10 +11,11 @@ $(eval $(call gb_UnpackedTarball_UnpackedTarball,libtiff))
 
 $(eval $(call gb_UnpackedTarball_set_tarball,libtiff,$(LIBTIFF_TARBALL)))
 
-$(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,0))
+$(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,1))
 
 $(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
 external/libtiff/libtiff.linknolibs.patch \
+external/libtiff/0001-ofz-54685-Timeout.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libtiff/libtiff.linknolibs.patch 
b/external/libtiff/libtiff.linknolibs.patch
index 0017ca9ca345..bd03af3a708d 100644
--- a/external/libtiff/libtiff.linknolibs.patch
+++ b/external/libtiff/libtiff.linknolibs.patch
@@ -1,5 +1,5 @@
 libtiff/Makefile.in2022-05-21 15:32:48.06327 +0100
-+++ libtiff/Makefile.in2022-05-21 15:32:59.051499293 +0100
+--- a/libtiff/Makefile.in  2022-05-21 15:32:48.06327 +0100
 b/libtiff/Makefile.in  2022-05-21 15:32:59.051499293 +0100
 @@ -372,7 +372,7 @@
  LDFLAGS = @LDFLAGS@
  LIBDIR = @LIBDIR@
diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx
index a3ce069cccf7..16c98003832f 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -81,6 +81,7 @@ static void outputMessage (j_common_ptr cinfo)
 
 extern "C" {
 
+// see also external/libtiff/0001-ofz-54685-Timeout.patch
 static void emitMessage (j_common_ptr cinfo, int msg_level)
 {
 if (msg_level < 0)


[Libreoffice-commits] core.git: external/libtiff

2022-06-10 Thread Stephan Bergmann (via logerrit)
 external/libtiff/UnpackedTarball_libtiff.mk |1 +
 external/libtiff/include.patch  |   10 ++
 2 files changed, 11 insertions(+)

New commits:
commit 12ffb0cb65352307485913065f4c3b5d8069ece7
Author: Stephan Bergmann 
AuthorDate: Fri Jun 10 08:07:43 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Fri Jun 10 09:46:49 2022 +0200

external/libtiff: Missing include for _byteswap_uint64 on Windows

...now causing a -Wimplicit-function-declaration error with Clang 15 trunk 
after


"[C11/C2x] Change the behavior of the implicit function declaration 
warning".

(Unconditionally including  on all platforms even for those that 
don't
need it should be harmless.)

Change-Id: Ic2191308ea252cb4b88842a2767167ab2d23d9fb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135572
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index db299319aa17..3e7abee6aef2 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,0))
 $(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
 external/libtiff/libtiff.linknolibs.patch \
 external/libtiff/0001-add-16bit-cielab-support.patch \
+external/libtiff/include.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libtiff/include.patch b/external/libtiff/include.patch
new file mode 100644
index ..0b6526234123
--- /dev/null
+++ b/external/libtiff/include.patch
@@ -0,0 +1,10 @@
+--- libtiff/tif_lzw.c
 libtiff/tif_lzw.c
+@@ -39,6 +39,7 @@
+ 
+ #include 
+ #include 
++#include 
+ 
+ /* Select the plausible largest natural integer type for the architecture */
+ #define SIZEOF_WORDTYPE SIZEOF_SIZE_T


[Libreoffice-commits] core.git: external/libtiff

2022-06-09 Thread Caolán McNamara (via logerrit)
 external/libtiff/0001-add-16bit-cielab-support.patch |  164 +++
 external/libtiff/UnpackedTarball_libtiff.mk  |2 
 external/libtiff/libtiff.16bitcielab.patch   |   75 
 3 files changed, 165 insertions(+), 76 deletions(-)

New commits:
commit 88fbab01861064cd353c38b39b4359154d3495ce
Author: Caolán McNamara 
AuthorDate: Thu Jun 9 10:34:39 2022 +0100
Commit: Caolán McNamara 
CommitDate: Thu Jun 9 13:48:12 2022 +0200

ofz#47901 fix read overflow

Change-Id: I707fe54e68ef548edcb8b69b83ba64c0674e44ce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135532
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/0001-add-16bit-cielab-support.patch 
b/external/libtiff/0001-add-16bit-cielab-support.patch
new file mode 100644
index ..3ee6c3f648ca
--- /dev/null
+++ b/external/libtiff/0001-add-16bit-cielab-support.patch
@@ -0,0 +1,164 @@
+From 87cf58d0604e4bfd70da1044894c3e8f073133a1 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= 
+Date: Sun, 22 May 2022 14:20:21 +0100
+Subject: [PATCH] add 16bit-cielab support
+
+add an internal TIFFCIELab16ToXYZ that assumes 16bit encoding
+
+multiply the 8bit variant input to use that, keep TIFFCIELabToXYZ
+unchanged so no different to existing potential consumers
+
+motivation: https://bugs.documentfoundation.org/show_bug.cgi?id=131199
+the "clavijo16bitlab.tiff" example where tiffinfo says:
+
+  Image Width: 2601 Image Length: 3503
+  Resolution: 96, 96 pixels/inch
+  Bits/Sample: 16
+  Compression Scheme: AdobeDeflate
+  Photometric Interpretation: CIE L*a*b*
+  Orientation: row 0 top, col 0 lhs
+  Samples/Pixel: 3
+  Rows/Strip: 1
+  Planar Configuration: single image plane
+  DateTime: 2020:03:07 10:20:42
+---
+ libtiff/tif_color.c| 19 ---
+ libtiff/tif_getimage.c | 38 ++
+ libtiff/tiffiop.h  |  2 ++
+ 3 files changed, 52 insertions(+), 7 deletions(-)
+
+diff --git a/libtiff/tif_color.c b/libtiff/tif_color.c
+index 20e41684..e0fc4bf0 100644
+--- libtiff/tif_color.c
 libtiff/tif_color.c
+@@ -44,7 +44,20 @@ void
+ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b,
+ float *X, float *Y, float *Z)
+ {
+-  float L = (float)l * 100.0F / 255.0F;
++  TIFFCIELab16ToXYZ(cielab, l * 257, a * 256, b * 256, X, Y, Z);
++}
++
++/*
++ * For CIELab encoded in 16 bits, L is an unsigned integer range [0,65535].
++ * The a* and b* components are signed integers range [-32768,32767]. The 16
++ * bit chrominance values are encoded as 256 times the 1976 CIE a* and b*
++ * values
++ */
++void
++TIFFCIELab16ToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, int32_t a, int32_t b,
++  float *X, float *Y, float *Z)
++{
++  float L = (float)l * 100.0F / 65535.0F;
+   float cby, tmp;
+ 
+   if( L < 8.856F ) {
+@@ -55,13 +68,13 @@ TIFFCIELabToXYZ(TIFFCIELabToRGB *cielab, uint32_t l, 
int32_t a, int32_t b,
+   *Y = cielab->Y0 * cby * cby * cby;
+   }
+ 
+-  tmp = (float)a / 500.0F + cby;
++  tmp = (float)a / 256.0F / 500.0F + cby;
+   if( tmp < 0.2069F )
+   *X = cielab->X0 * (tmp - 0.13793F) / 7.787F;
+   else
+   *X = cielab->X0 * tmp * tmp * tmp;
+ 
+-  tmp = cby - (float)b / 200.0F;
++  tmp = cby - (float)b / 256.0F / 200.0F;
+   if( tmp < 0.2069F )
+   *Z = cielab->Z0 * (tmp - 0.13793F) / 7.787F;
+   else
+diff --git a/libtiff/tif_getimage.c b/libtiff/tif_getimage.c
+index a1b6570b..9e2ac2c9 100644
+--- libtiff/tif_getimage.c
 libtiff/tif_getimage.c
+@@ -194,7 +194,7 @@ TIFFRGBAImageOK(TIFF* tif, char emsg[1024])
+ }
+   break;
+   case PHOTOMETRIC_CIELAB:
+-if ( td->td_samplesperpixel != 3 || colorchannels != 
3 || td->td_bitspersample != 8 ) {
++if ( td->td_samplesperpixel != 3 || colorchannels != 
3 || (td->td_bitspersample != 8 && td->td_bitspersample != 16) ) {
+ sprintf(emsg,
+ "Sorry, can not handle image with 
%s=%"PRIu16", %s=%d and %s=%"PRIu16,
+ "Samples/pixel", 
td->td_samplesperpixel,
+@@ -1784,7 +1784,7 @@ DECLARESepPutFunc(putRGBUAseparate16bittile)
+ /*
+  * 8-bit packed CIE L*a*b 1976 samples => RGB
+  */
+-DECLAREContigPutFunc(putcontig8bitCIELab)
++DECLAREContigPutFunc(putcontig8bitCIELab8)
+ {
+   float X, Y, Z;
+   uint32_t r, g, b;
+@@ -1806,6 +1806,32 @@ DECLAREContigPutFunc(putcontig8bitCIELab)
+   }
+ }
+ 
++/*
++ * 16-bit packed CIE L*a*b 1976 samples => RGB
++ */
++DECLAREContigPutFunc(putcontig8bitCIELab16)
++{
++  float X, Y, Z;
++  uint32_t r, g, b;
++  uint16_t *wp = (uint16_t *)pp;
++  (void) y;
++  fromskew *= 3;
++  for( ; h > 0; --h) {
++  for (x = w; x > 0; 

[Libreoffice-commits] core.git: external/libtiff

2022-06-08 Thread Jan-Marek Glogowski (via logerrit)
 external/libtiff/ExternalProject_libtiff.mk |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 98cfc7db5ed352b2ddb9a547c7f88abb83264cef
Author: Jan-Marek Glogowski 
AuthorDate: Wed Jun 8 17:44:56 2022 +0200
Commit: Jan-Marek Glogowski 
CommitDate: Wed Jun 8 18:53:32 2022 +0200

libtiff WASM: add Emscripten flags to fix NEH build

Change-Id: I3ea1ca064cdddee1bea6b5816f63f0e4a93217de
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135505
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski 

diff --git a/external/libtiff/ExternalProject_libtiff.mk 
b/external/libtiff/ExternalProject_libtiff.mk
index 04af18322541..e318126dcfe0 100644
--- a/external/libtiff/ExternalProject_libtiff.mk
+++ b/external/libtiff/ExternalProject_libtiff.mk
@@ -50,7 +50,7 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
--with-pic \
--without-x \
$(if 
$(verbose),--disable-silent-rules,--enable-silent-rules) \
-   CFLAGS="$(CFLAGS) $(call 
gb_ExternalProject_get_build_flags,libtiff)" \
+   CFLAGS="$(CFLAGS) $(call 
gb_ExternalProject_get_build_flags,libtiff) $(gb_EMSCRIPTEN_CFLAGS)" \
$(if $(SYSTEM_ZLIB),,--with-zlib-include-dir="$(call 
gb_UnpackedTarball_get_dir,zlib)") \
$(if 
$(SYSTEM_ZLIB),,--with-zlib-lib-dir="$(gb_StaticLibrary_WORKDIR)") \
$(if $(SYSTEM_LIBJPEG),,--with-jpeg-include-dir="$(call 
gb_UnpackedTarball_get_dir,libjpeg-turbo)") \
@@ -59,8 +59,8 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
$(if $(SYSTEM_LIBWEBP),,$(if $(filter 
WNT,$(OS_FOR_BUILD)),\
--with-webp-lib-dir="$(call 
gb_UnpackedTarball_get_dir,libwebp)/output/lib/libwebp$(if 
$(MSVC_USE_DEBUG_RUNTIME),_debug)$(gb_StaticLibrary_PLAINEXT)", \
--with-webp-lib-dir="$(call 
gb_UnpackedTarball_get_dir,libwebp)/src/.libs")) \
-   CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS)" \
-   LDFLAGS="$(call 
gb_ExternalProject_get_link_flags,libtiff)" \
+   CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS) 
$(gb_EMSCRIPTEN_CPPFLAGS)" \
+   LDFLAGS="$(call 
gb_ExternalProject_get_link_flags,libtiff) $(gb_EMSCRIPTEN_LDFLAGS)" \
ac_cv_lib_z_inflateEnd=yes \
ac_cv_lib_jpeg_jpeg_read_scanlines=yes \
ac_cv_lib_webp_WebPDecode=yes \


[Libreoffice-commits] core.git: external/libtiff

2022-05-23 Thread Stephan Bergmann (via logerrit)
 external/libtiff/UnpackedTarball_libtiff.mk |1 +
 external/libtiff/ubsan.patch|   11 +++
 2 files changed, 12 insertions(+)

New commits:
commit 91f408fd94cf38b27dcb26ced9cd6c4e1a9d1cd2
Author: Stephan Bergmann 
AuthorDate: Mon May 23 15:05:47 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Mon May 23 21:59:21 2022 +0200

external/libtiff: Silence invalid-null-argument

...during CppunitTest_vcl_filters_test,

> tif_dirread.c:4176:40: runtime error: null pointer passed as argument 2, 
which is declared to never be null
> /usr/include/string.h:44:28: note: nonnull attribute specified here
>  #0 in TIFFReadDirectory at 
workdir/UnpackedTarball/libtiff/libtiff/tif_dirread.c:4176:17 
(instdir/program/libvcllo.so +0xc4dbb6d)
>  #1 in ImportTiffGraphicImport(SvStream&, Graphic&) at 
vcl/source/filter/itiff/itiff.cxx:238:14 (instdir/program/libvcllo.so 
+0xa691680)
>  #2 in TiffFilterTest::load(rtl::OUString const&, rtl::OUString const&, 
rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at 
vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx:70:12 
(workdir/LinkTarget/CppunitTest/libtest_vcl_filters_test.so +0x16dc48)
>  #3 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString 
const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, 
SotClipboardFormatId, unsigned int, bool) at 
unotest/source/cpp/filters-test.cxx:132:20 
(workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0xd8d5c)
>  #4 in test::FiltersTest::testDir(rtl::OUString const&, 
std::basic_string_view>, rtl::OUString 
const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at 
unotest/source/cpp/filters-test.cxx:160:5 
(workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0xdcc71)
>  #5 in TiffFilterTest::testCVEs() at 
vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx:76:5 
(workdir/LinkTarget/CppunitTest/libtest_vcl_filters_test.so +0x16e1c5)

Change-Id: I2de4363ff0f5552e89fd0af84b7b88e38b7bb209
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134823
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index ee3d4ab6cb27..f874d6d61743 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -16,6 +16,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,0))
 $(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
 external/libtiff/libtiff.linknolibs.patch \
 external/libtiff/libtiff.16bitcielab.patch \
+external/libtiff/ubsan.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libtiff/ubsan.patch b/external/libtiff/ubsan.patch
new file mode 100644
index ..853d069ad795
--- /dev/null
+++ b/external/libtiff/ubsan.patch
@@ -0,0 +1,11 @@
+--- libtiff/tif_dirread.c
 libtiff/tif_dirread.c
+@@ -4173,7 +4173,7 @@
+ goto bad;
+ }
+ 
+-memcpy(new_sampleinfo, tif->tif_dir.td_sampleinfo, 
old_extrasamples * sizeof(uint16_t));
++if (old_extrasamples != 0) memcpy(new_sampleinfo, 
tif->tif_dir.td_sampleinfo, old_extrasamples * sizeof(uint16_t));
+ _TIFFsetShortArray(>tif_dir.td_sampleinfo, 
new_sampleinfo, tif->tif_dir.td_extrasamples);
+ _TIFFfree(new_sampleinfo);
+ }


[Libreoffice-commits] core.git: external/libtiff

2022-05-23 Thread Julien Nabet (via logerrit)
 external/libtiff/README |3 +++
 1 file changed, 3 insertions(+)

New commits:
commit a14d8acb93717b958598421590831e8a92fde27c
Author: Julien Nabet 
AuthorDate: Mon May 23 13:40:15 2022 +0200
Commit: Caolán McNamara 
CommitDate: Mon May 23 18:16:43 2022 +0200

README libtiff

Change-Id: Icece0daad46896334cba7dc66435351a347bd2cb
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134819
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/README b/external/libtiff/README
new file mode 100644
index ..a650ea584a6a
--- /dev/null
+++ b/external/libtiff/README
@@ -0,0 +1,3 @@
+libtiff is a library to encode and decode images in TIFF format, from 
[http://download.osgeo.org/libtiff/]
+
+For the moment we use it only for decoding part.


[Libreoffice-commits] core.git: external/libtiff

2022-05-22 Thread Caolán McNamara (via logerrit)
 external/libtiff/UnpackedTarball_libtiff.mk |1 
 external/libtiff/libtiff.16bitcielab.patch  |   75 
 2 files changed, 76 insertions(+)

New commits:
commit 5b74eb7d41bbcf2d35154ae8272f0e71be128b60
Author: Caolán McNamara 
AuthorDate: Sun May 22 14:12:13 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sun May 22 21:30:20 2022 +0200

tdf#131199 add some basic 16bitcielab support

to get that final tiff loadable

Change-Id: Ia772c06521c93ac860e9d3014706d677f16c8d4e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134734
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index ce5a3a53d36a..ee3d4ab6cb27 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,0))
 
 $(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
 external/libtiff/libtiff.linknolibs.patch \
+external/libtiff/libtiff.16bitcielab.patch \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/libtiff/libtiff.16bitcielab.patch 
b/external/libtiff/libtiff.16bitcielab.patch
new file mode 100644
index ..cecce9cd8402
--- /dev/null
+++ b/external/libtiff/libtiff.16bitcielab.patch
@@ -0,0 +1,75 @@
+--- libtiff/tif_getimage.c 2021-03-05 13:01:43.0 +
 libtiff/tif_getimage.c 2022-05-22 14:05:56.320883484 +0100
+@@ -194,7 +194,7 @@
+ }
+   break;
+   case PHOTOMETRIC_CIELAB:
+-if ( td->td_samplesperpixel != 3 || colorchannels != 
3 || td->td_bitspersample != 8 ) {
++if ( td->td_samplesperpixel != 3 || colorchannels != 
3 || (td->td_bitspersample != 8 && td->td_bitspersample != 16) ) {
+ sprintf(emsg,
+ "Sorry, can not handle image with 
%s=%"PRIu16", %s=%d and %s=%"PRIu16,
+ "Samples/pixel", 
td->td_samplesperpixel,
+@@ -1784,7 +1784,7 @@
+ /*
+  * 8-bit packed CIE L*a*b 1976 samples => RGB
+  */
+-DECLAREContigPutFunc(putcontig8bitCIELab)
++DECLAREContigPutFunc(putcontig8bitCIELab8)
+ {
+   float X, Y, Z;
+   uint32_t r, g, b;
+@@ -1807,6 +1807,32 @@
+ }
+ 
+ /*
++ * 16-bit packed CIE L*a*b 1976 samples => RGB
++ */
++DECLAREContigPutFunc(putcontig8bitCIELab16)
++{
++  float X, Y, Z;
++  uint32_t r, g, b;
++uint16_t *wp = (uint16_t *)pp;
++  (void) y;
++  fromskew = 3;
++  for( ; h > 0; --h) {
++  for (x = w; x > 0; --x) {
++  TIFFCIELabToXYZ(img->cielab,
++  wp[0] / 256,
++  wp[1] / 256,
++  wp[2] / 256,
++  , , );
++  TIFFXYZToRGB(img->cielab, X, Y, Z, , , );
++  *cp++ = PACK(r, g, b);
++  wp += 3;
++  }
++  cp += toskew;
++  wp += fromskew;
++  }
++}
++
++/*
+  * YCbCr -> RGB conversion and packing routines.
+  */
+ 
+@@ -2395,7 +2421,11 @@
+   return NULL;
+   }
+ 
+-  return putcontig8bitCIELab;
++  if (img->bitspersample == 8)
++  return putcontig8bitCIELab8;
++  else if (img->bitspersample == 16)
++  return putcontig8bitCIELab16;
++  return NULL;
+ }
+ 
+ /*
+@@ -2777,7 +2807,7 @@
+   break;
+   case PHOTOMETRIC_CIELAB:
+   if (img->samplesperpixel == 3 && buildMap(img)) {
+-  if (img->bitspersample == 8)
++  if (img->bitspersample == 8 || 
img->bitspersample == 16)
+   img->put.contig = 
initCIELabConversion(img);
+   break;
+   }


[Libreoffice-commits] core.git: external/libtiff RepositoryExternal.mk

2022-05-21 Thread Caolán McNamara (via logerrit)
 RepositoryExternal.mk   |8 ++--
 external/libtiff/ExternalProject_libtiff.mk |8 +++-
 2 files changed, 9 insertions(+), 7 deletions(-)

New commits:
commit 11e4235930f05906311f7b70444b0a6487d59a47
Author: Caolán McNamara 
AuthorDate: Sat May 21 16:30:59 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 21 20:06:24 2022 +0200

tiff: enable webp

Change-Id: Ifd277fd89393f964817bf58dead53074321252d8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134711
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/RepositoryExternal.mk b/RepositoryExternal.mk
index 1e2329d69339..6b3ae0cafd8b 100644
--- a/RepositoryExternal.mk
+++ b/RepositoryExternal.mk
@@ -2649,9 +2649,7 @@ $(call gb_LinkTarget_use_external_project,$(1),libtiff)
 endef
 
 define gb_ExternalProject__use_libtiff
-$(call gb_ExternalProject_use_external_project,$(1),\
-   libtiff \
-)
+$(call gb_ExternalProject_use_external_project,$(1),libtiff)
 
 endef
 
@@ -2699,9 +2697,7 @@ $(call gb_LinkTarget_use_external_project,$(1),libwebp)
 endef
 
 define gb_ExternalProject__use_libwebp
-$(call gb_ExternalProject_use_external_project,$(1),\
-   libwebp \
-)
+$(call gb_ExternalProject_use_external_project,$(1),libwebp)
 
 endef
 
diff --git a/external/libtiff/ExternalProject_libtiff.mk 
b/external/libtiff/ExternalProject_libtiff.mk
index e9ecbdf86765..04af18322541 100644
--- a/external/libtiff/ExternalProject_libtiff.mk
+++ b/external/libtiff/ExternalProject_libtiff.mk
@@ -15,6 +15,7 @@ $(eval $(call gb_ExternalProject_register_targets,libtiff,\
 
 $(eval $(call gb_ExternalProject_use_externals,libtiff,\
 libjpeg \
+libwebp \
 zlib \
 ))
 
@@ -36,6 +37,7 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
--enable-static \
--enable-jpeg \
--enable-zlib \
+   --enable-webp \
--disable-shared \
--disable-cxx \
--disable-libdeflate \
@@ -43,7 +45,6 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
--disable-lerc \
--disable-lzma \
--disable-mdi \
-   --disable-webp \
--disable-win32-io \
--disable-zstd \
--with-pic \
@@ -54,10 +55,15 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
$(if 
$(SYSTEM_ZLIB),,--with-zlib-lib-dir="$(gb_StaticLibrary_WORKDIR)") \
$(if $(SYSTEM_LIBJPEG),,--with-jpeg-include-dir="$(call 
gb_UnpackedTarball_get_dir,libjpeg-turbo)") \
$(if 
$(SYSTEM_LIBJPEG),,--with-jpeg-lib-dir="$(gb_StaticLibrary_WORKDIR)") \
+   $(if $(SYSTEM_LIBWEBP),,--with-webp-include-dir="$(call 
gb_UnpackedTarball_get_dir,libwebp/src)") \
+   $(if $(SYSTEM_LIBWEBP),,$(if $(filter 
WNT,$(OS_FOR_BUILD)),\
+   --with-webp-lib-dir="$(call 
gb_UnpackedTarball_get_dir,libwebp)/output/lib/libwebp$(if 
$(MSVC_USE_DEBUG_RUNTIME),_debug)$(gb_StaticLibrary_PLAINEXT)", \
+   --with-webp-lib-dir="$(call 
gb_UnpackedTarball_get_dir,libwebp)/src/.libs")) \
CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS)" \
LDFLAGS="$(call 
gb_ExternalProject_get_link_flags,libtiff)" \
ac_cv_lib_z_inflateEnd=yes \
ac_cv_lib_jpeg_jpeg_read_scanlines=yes \
+   ac_cv_lib_webp_WebPDecode=yes \
$(gb_CONFIGURE_PLATFORMS) \
&& cd libtiff && $(MAKE) libtiff.la \
)


[Libreoffice-commits] core.git: external/libtiff

2022-05-21 Thread Caolán McNamara (via logerrit)
 external/libtiff/ExternalProject_libtiff.mk |   26 +++---
 external/libtiff/UnpackedTarball_libtiff.mk |4 
 external/libtiff/libtiff.linknolibs.patch   |   11 +++
 3 files changed, 38 insertions(+), 3 deletions(-)

New commits:
commit 685eff8c9e6e6097b6f9e365fd6554e10adef063
Author: Caolán McNamara 
AuthorDate: Fri May 20 09:51:19 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 21 17:25:46 2022 +0200

libtiff: enable jpeg and zlib

Change-Id: Ied6ab75342f5cdaadefbff7f75fbe63e9d67e992
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134667
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/ExternalProject_libtiff.mk 
b/external/libtiff/ExternalProject_libtiff.mk
index c973ca025dd9..e9ecbdf86765 100644
--- a/external/libtiff/ExternalProject_libtiff.mk
+++ b/external/libtiff/ExternalProject_libtiff.mk
@@ -13,33 +13,53 @@ $(eval $(call gb_ExternalProject_register_targets,libtiff,\
build \
 ))
 
+$(eval $(call gb_ExternalProject_use_externals,libtiff,\
+libjpeg \
+zlib \
+))
+
 $(eval $(call gb_ExternalProject_use_autoconf,libtiff,build))
 
+# using ac_cv_lib_z_inflateEnd=yes to skip test for our
+# static windows lib where the name is zlib not z
+# using ac_cv_lib_jpeg_jpeg_read_scanlines to skip test
+# for our static windows lib where the name is libjpeg-turbo.lib
+# not libjpeg.lib
+# we're building this statically anyway so the lib isn't
+# used during the link done here
+
 $(call gb_ExternalProject_get_state_target,libtiff,build) :
$(call gb_Trace_StartRange,libtiff,EXTERNAL)
$(call gb_ExternalProject_run,build,\
export PKG_CONFIG="" \
&& MAKE=$(MAKE) $(gb_RUN_CONFIGURE) ./configure \
--enable-static \
-   --with-pic \
+   --enable-jpeg \
+   --enable-zlib \
--disable-shared \
--disable-cxx \
--disable-libdeflate \
--disable-jbig \
-   --disable-jpeg \
--disable-lerc \
--disable-lzma \
--disable-mdi \
--disable-webp \
--disable-win32-io \
--disable-zstd \
+   --with-pic \
--without-x \
$(if 
$(verbose),--disable-silent-rules,--enable-silent-rules) \
CFLAGS="$(CFLAGS) $(call 
gb_ExternalProject_get_build_flags,libtiff)" \
+   $(if $(SYSTEM_ZLIB),,--with-zlib-include-dir="$(call 
gb_UnpackedTarball_get_dir,zlib)") \
+   $(if 
$(SYSTEM_ZLIB),,--with-zlib-lib-dir="$(gb_StaticLibrary_WORKDIR)") \
+   $(if $(SYSTEM_LIBJPEG),,--with-jpeg-include-dir="$(call 
gb_UnpackedTarball_get_dir,libjpeg-turbo)") \
+   $(if 
$(SYSTEM_LIBJPEG),,--with-jpeg-lib-dir="$(gb_StaticLibrary_WORKDIR)") \
CPPFLAGS="$(CPPFLAGS) $(BOOST_CPPFLAGS)" \
LDFLAGS="$(call 
gb_ExternalProject_get_link_flags,libtiff)" \
+   ac_cv_lib_z_inflateEnd=yes \
+   ac_cv_lib_jpeg_jpeg_read_scanlines=yes \
$(gb_CONFIGURE_PLATFORMS) \
-   && $(MAKE) \
+   && cd libtiff && $(MAKE) libtiff.la \
)
$(call gb_Trace_EndRange,libtiff,EXTERNAL)
 
diff --git a/external/libtiff/UnpackedTarball_libtiff.mk 
b/external/libtiff/UnpackedTarball_libtiff.mk
index 30701edc56cf..ce5a3a53d36a 100644
--- a/external/libtiff/UnpackedTarball_libtiff.mk
+++ b/external/libtiff/UnpackedTarball_libtiff.mk
@@ -13,4 +13,8 @@ $(eval $(call 
gb_UnpackedTarball_set_tarball,libtiff,$(LIBTIFF_TARBALL)))
 
 $(eval $(call gb_UnpackedTarball_set_patchlevel,libtiff,0))
 
+$(eval $(call gb_UnpackedTarball_add_patches,libtiff,\
+external/libtiff/libtiff.linknolibs.patch \
+))
+
 # vim: set noet sw=4 ts=4:
diff --git a/external/libtiff/libtiff.linknolibs.patch 
b/external/libtiff/libtiff.linknolibs.patch
new file mode 100644
index ..0017ca9ca345
--- /dev/null
+++ b/external/libtiff/libtiff.linknolibs.patch
@@ -0,0 +1,11 @@
+--- libtiff/Makefile.in2022-05-21 15:32:48.06327 +0100
 libtiff/Makefile.in2022-05-21 15:32:59.051499293 +0100
+@@ -372,7 +372,7 @@
+ LDFLAGS = @LDFLAGS@
+ LIBDIR = @LIBDIR@
+ LIBOBJS = @LIBOBJS@
+-LIBS = @LIBS@
++#LIBS = @LIBS@
+ LIBTIFF_ALPHA_VERSION = @LIBTIFF_ALPHA_VERSION@
+ LIBTIFF_DOCDIR = @LIBTIFF_DOCDIR@
+ LIBTIFF_MAJOR_VERSION = @LIBTIFF_MAJOR_VERSION@


[Libreoffice-commits] core.git: external/libtiff

2022-05-21 Thread Caolán McNamara (via logerrit)
 external/libtiff/ExternalProject_libtiff.mk |2 ++
 1 file changed, 2 insertions(+)

New commits:
commit f948108d85a3e7a965e61e22999d29d321acba94
Author: Caolán McNamara 
AuthorDate: Sat May 21 15:04:46 2022 +0100
Commit: Caolán McNamara 
CommitDate: Sat May 21 17:03:20 2022 +0200

explicitly disable some things that might otherwise get enabled

depending on what happens to be installed on the build system

Change-Id: Ic0c3eed721aeba6361aa6da82b467891d24d7557
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134709
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/external/libtiff/ExternalProject_libtiff.mk 
b/external/libtiff/ExternalProject_libtiff.mk
index 9933a4cf947c..c973ca025dd9 100644
--- a/external/libtiff/ExternalProject_libtiff.mk
+++ b/external/libtiff/ExternalProject_libtiff.mk
@@ -24,8 +24,10 @@ $(call gb_ExternalProject_get_state_target,libtiff,build) :
--with-pic \
--disable-shared \
--disable-cxx \
+   --disable-libdeflate \
--disable-jbig \
--disable-jpeg \
+   --disable-lerc \
--disable-lzma \
--disable-mdi \
--disable-webp \