From 6975007f314a4c392e2cb616e7c3297ed167c2a7 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Tue, 27 Dec 2016 12:45:28 +0100 Subject: Bug 697455: Make JPX support optional via configuration flag. Set FZ_ENABLE_JPX=0 in XCFLAGS or include/mupdf/fitz/config.h to disable support for JPX at compile time. Be aware that this may break support for PDF 1.5 and later files that need JPEG2000 support. --- include/mupdf/fitz/config.h | 12 ++++++++++++ source/fitz/load-jpx.c | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/mupdf/fitz/config.h b/include/mupdf/fitz/config.h index 995ac87b..97d399b9 100644 --- a/include/mupdf/fitz/config.h +++ b/include/mupdf/fitz/config.h @@ -29,6 +29,14 @@ /* #define FZ_ENABLE_EPUB 1 */ /* #define FZ_ENABLE_GPRF 1 */ +/* + Choose whether to enable JPEG2000 decoding. + By default, it is enabled, but due to frequent security + issues with the third party libraries we support disabling + it with this flag. +*/ +/* #define FZ_ENABLE_JPX 1 */ + /* Choose whether to enable JavaScript. By default JavaScript is enabled both for mutool and PDF interactivity. @@ -131,6 +139,10 @@ #define FZ_ENABLE_GPRF 0 #endif /* FZ_ENABLE_GPRF */ +#ifndef FZ_ENABLE_JPX +#define FZ_ENABLE_JPX 1 +#endif /* FZ_ENABLE_JPX */ + #ifndef FZ_ENABLE_JS #define FZ_ENABLE_JS 1 #endif /* FZ_ENABLE_JS */ diff --git a/source/fitz/load-jpx.c b/source/fitz/load-jpx.c index ef99d154..9baad51d 100644 --- a/source/fitz/load-jpx.c +++ b/source/fitz/load-jpx.c @@ -1,5 +1,7 @@ #include "mupdf/fitz.h" +#if FZ_ENABLE_JPX + typedef struct fz_jpxd_s fz_jpxd; typedef struct stream_block_s stream_block; @@ -918,3 +920,19 @@ fz_load_jpx_info(fz_context *ctx, unsigned char *data, size_t size, int *wp, int } #endif /* HAVE_LURATECH */ + +#else /* FZ_ENABLE_JPX */ + +fz_pixmap * +fz_load_jpx(fz_context *ctx, unsigned char *data, size_t size, fz_colorspace *defcs) +{ + fz_throw(ctx, FZ_ERROR_GENERIC, "JPX support disabled"); +} + +void +fz_load_jpx_info(fz_context *ctx, unsigned char *data, size_t size, int *wp, int *hp, int *xresp, int *yresp, fz_colorspace **cspacep) +{ + fz_throw(ctx, FZ_ERROR_GENERIC, "JPX support disabled"); +} + +#endif -- cgit v1.2.3