···11{ stdenv, fetchzip, fetchurl, fetchpatch, cmake, pkgconfig
22-, zlib, libpng
22+, zlib, libpng, openjpeg
33, enableGSL ? true, gsl
44, enableGhostScript ? true, ghostscript
55, enableMuPDF ? true, mupdf
···4040 # Patches from previous 1.10a version in nixpkgs
4141 patches = [
4242 # Compatibility with new openjpeg
4343- (fetchpatch {
4444- name = "mupdf-1.9a-openjpeg-2.1.1.patch";
4545- url = "https://git.archlinux.org/svntogit/community.git/plain/mupdf/trunk/0001-mupdf-openjpeg.patch?id=5a28ad0a8999a9234aa7848096041992cc988099";
4646- sha256 = "1i24qr4xagyapx4bijjfksj4g3bxz8vs5c2mn61nkm29c63knp75";
4747- })
4343+ ./load-jpx.patch
48444945 (fetchurl {
5046 name = "CVE-2017-5896.patch";
···6460 # Don't remove mujs because upstream version is incompatible
6561 rm -rf thirdparty/{curl,freetype,glfw,harfbuzz,jbig2dec,jpeg,openjpeg,zlib}
6662 '';
6363+ postPatch = let
6464+ # OpenJPEG version is hardcoded in package source
6565+ openJpegVersion = with stdenv;
6666+ lib.concatStringsSep "." (lib.lists.take 2
6767+ (lib.splitString "." (lib.getVersion openjpeg)));
6868+ in ''
6969+ sed -i "s/__OPENJPEG__VERSION__/${openJpegVersion}/" source/fitz/load-jpx.c
7070+ '';
6771 });
6872 leptonica_modded = leptonica.overrideAttrs (attrs: {
6973 prePatch = ''
+29
pkgs/applications/misc/k2pdfopt/load-jpx.patch
···11+--- a/source/fitz/load-jpx.c
22++++ b/source/fitz/load-jpx.c
33+@@ -484,12 +484,16 @@
44+ /* Without the definition of OPJ_STATIC, compilation fails on windows
55+ * due to the use of __stdcall. We believe it is required on some
66+ * linux toolchains too. */
77++#ifdef __cplusplus
88++extern "C"
99++{
1010+ #define OPJ_STATIC
1111+ #ifndef _MSC_VER
1212+ #define OPJ_HAVE_STDINT_H
1313+ #endif
1414++#endif
1515+1616+-#include <openjpeg.h>
1717++#include <openjpeg-__OPENJPEG__VERSION__/openjpeg.h>
1818+1919+ /* OpenJPEG does not provide a safe mechanism to intercept
2020+ * allocations. In the latest version all allocations go
2121+@@ -971,4 +975,8 @@
2222+ fz_drop_pixmap(ctx, img);
2323+ }
2424+2525++#ifdef __cplusplus
2626++}
2727++#endif
2828++
2929+ #endif /* HAVE_LURATECH */