From d934827bf44b7cfcf6711964418148fa60877668 Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Wed, 25 Nov 2020 22:39:15 +0000 Subject: gentoo resync : 25.11.2020 --- app-text/mupdf/files/mupdf-1.14-libressl.patch | 45 -------- app-text/mupdf/files/mupdf-1.18-Makefile.patch | 42 +++++++ .../mupdf/files/mupdf-1.18.0-cross-fixes.patch | 128 +++++++++++++++++++++ .../files/mupdf-1.18.0-fix-oob-in-pdf-layer.c | 102 ++++++++++++++++ .../mupdf/files/mupdf-1.18.0-fix-oob-in-pixmap.c | 41 +++++++ 5 files changed, 313 insertions(+), 45 deletions(-) delete mode 100644 app-text/mupdf/files/mupdf-1.14-libressl.patch create mode 100644 app-text/mupdf/files/mupdf-1.18-Makefile.patch create mode 100644 app-text/mupdf/files/mupdf-1.18.0-cross-fixes.patch create mode 100644 app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pdf-layer.c create mode 100644 app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pixmap.c (limited to 'app-text/mupdf/files') diff --git a/app-text/mupdf/files/mupdf-1.14-libressl.patch b/app-text/mupdf/files/mupdf-1.14-libressl.patch deleted file mode 100644 index fcc0a7205c1c..000000000000 --- a/app-text/mupdf/files/mupdf-1.14-libressl.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 8561b744ac95ab6145a1163fa1d7c490a3329465 Mon Sep 17 00:00:00 2001 -From: William -Date: Mon, 12 Nov 2018 16:50:07 +0100 -Subject: [PATCH] hardcode missing ssl functions - ---- - source/helpers/pkcs7/pkcs7-openssl.c | 22 ++++++++++++++++++++++ - 1 file changed, 22 insertions(+) - -diff --git a/source/helpers/pkcs7/pkcs7-openssl.c b/source/helpers/pkcs7/pkcs7-openssl.c -index 58dbf65..2b1f9e9 100644 ---- a/source/helpers/pkcs7/pkcs7-openssl.c -+++ b/source/helpers/pkcs7/pkcs7-openssl.c -@@ -511,6 +511,28 @@ static void signer_drop_designated_name(pdf_pkcs7_signer *signer, pdf_pkcs7_desi - fz_free(osigner->ctx, dn); - } - -+int -+PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag) -+{ -+ return OBJ_obj2nid(bag->type); -+} -+ -+const STACK_OF(PKCS12_SAFEBAG) * -+PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag) -+{ -+ if (OBJ_obj2nid(bag->type) != NID_safeContentsBag) -+ return NULL; -+ return bag->value.safes; -+} -+ -+const PKCS8_PRIV_KEY_INFO * -+PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag) -+{ -+ if (PKCS12_SAFEBAG_get_nid(bag) != NID_keyBag) -+ return NULL; -+ return bag->value.keybag; -+} -+ - static void add_from_bags(X509 **pX509, EVP_PKEY **pPkey, const STACK_OF(PKCS12_SAFEBAG) *bags, const char *pw); - - static void add_from_bag(X509 **pX509, EVP_PKEY **pPkey, PKCS12_SAFEBAG *bag, const char *pw) --- -2.19.1 - diff --git a/app-text/mupdf/files/mupdf-1.18-Makefile.patch b/app-text/mupdf/files/mupdf-1.18-Makefile.patch new file mode 100644 index 000000000000..32ee7e57c493 --- /dev/null +++ b/app-text/mupdf/files/mupdf-1.18-Makefile.patch @@ -0,0 +1,42 @@ +diff --git a/Makefile b/Makefile +index b0fb617..528e117 100644 +--- a/Makefile ++++ b/Makefile +@@ -3,7 +3,7 @@ + -include user.make + + ifndef build +- build := release ++ build := debug + endif + + ifndef OUT +@@ -214,13 +214,15 @@ MUPDF_LIB = $(OUT)/libmupdf.$(SO) + + $(MUPDF_LIB) : $(MUPDF_OBJ) $(THIRD_OBJ) $(THREAD_OBJ) $(PKCS7_OBJ) + else +-MUPDF_LIB = $(OUT)/libmupdf.a +-THIRD_LIB = $(OUT)/libmupdf-third.a ++MUPDF_LIB = libmupdf.so.$(GENTOO_PV) ++MUPDF_STATIC = $(OUT)/libmupdf.a ++THIRD_LIB = + THREAD_LIB = $(OUT)/libmupdf-threads.a + PKCS7_LIB = $(OUT)/libmupdf-pkcs7.a + +-$(MUPDF_LIB) : $(MUPDF_OBJ) +-$(THIRD_LIB) : $(THIRD_OBJ) ++$(MUPDF_LIB) : $(MUPDF_OBJ) $(THIRD_OBJ) ++ $(QUIET_LINK) $(CC) $(LDFLAGS) --shared -Wl,-soname -Wl,$(MUPDF_LIB) -o $@ $^ $(THIRD_LIBS) $(LIBS) ++$(MUPDF_STATIC): $(MUPDF_OBJ) $(THIRD_OBJ) + $(THREAD_LIB) : $(THREAD_OBJ) + $(PKCS7_LIB) : $(PKCS7_OBJ) + endif +@@ -374,7 +376,7 @@ install: libs apps + + install -d $(DESTDIR)$(docdir) + install -d $(DESTDIR)$(docdir)/examples +- install -m 644 README COPYING CHANGES $(DESTDIR)$(docdir) ++ install -m 644 README CHANGES $(DESTDIR)$(docdir) + install -m 644 docs/*.html docs/*.css docs/*.png $(DESTDIR)$(docdir) + install -m 644 docs/examples/* $(DESTDIR)$(docdir)/examples + diff --git a/app-text/mupdf/files/mupdf-1.18.0-cross-fixes.patch b/app-text/mupdf/files/mupdf-1.18.0-cross-fixes.patch new file mode 100644 index 000000000000..0576033a03a2 --- /dev/null +++ b/app-text/mupdf/files/mupdf-1.18.0-cross-fixes.patch @@ -0,0 +1,128 @@ +Refreshed patches based on: +https://sources.debian.org/patches/mupdf/1.17.0+ds1-1/0004-MuPDF-crossbuild-use-target-arch-pkg-config.patch/ +https://sources.debian.org/patches/mupdf/1.17.0+ds1-1/0005-MuPDF-crossbuild-use-host-cc-for-utils.patch/ +--- a/Makefile ++++ b/Makefile +@@ -147,6 +147,9 @@ PKCS7_OBJ := $(PKCS7_SRC:%.c=$(OUT)/%.o) + + HEXDUMP_EXE := $(OUT)/scripts/hexdump.exe + ++$(HEXDUMP_EXE): scripts/hexdump.c ++ $(QUIET_CC) $(MKTGTDIR) ; $(CC_FOR_BUILD) $(CFLAGS) -o $@ $< ++ + FONT_BIN := $(sort $(wildcard resources/fonts/urw/*.cff)) + FONT_BIN += $(sort $(wildcard resources/fonts/han/*.ttc)) + FONT_BIN += $(sort $(wildcard resources/fonts/droid/*.ttf)) +--- a/Makerules ++++ b/Makerules +@@ -6,6 +6,9 @@ OS := $(OS:MSYS%=MINGW) + OS := $(OS:Windows_NT=MINGW) + OS := $(OS:Darwin=MACOS) + ++PKG_CONFIG ?= pkg-config ++CC_FOR_BUILD ?= $(CC) ++ + ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),) + # clang does not support these in combination with -fembed-bitcode + CFLAGS += -ffunction-sections -fdata-sections +@@ -128,51 +128,51 @@ else ifeq ($(OS),MACOS) + else ifeq ($(OS),Linux) + HAVE_OBJCOPY := yes + +- ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes) +- SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2) +- SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2) ++ ifeq ($(shell $(PKG_CONFIG) --exists freetype2 && echo yes),yes) ++ SYS_FREETYPE_CFLAGS := $(shell $(PKG_CONFIG) --cflags freetype2) ++ SYS_FREETYPE_LIBS := $(shell $(PKG_CONFIG) --libs freetype2) + endif +- ifeq ($(shell pkg-config --exists gumbo && echo yes),yes) +- SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo) +- SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo) ++ ifeq ($(shell $(PKG_CONFIG) --exists gumbo && echo yes),yes) ++ SYS_GUMBO_CFLAGS := $(shell $(PKG_CONFIG) --cflags gumbo) ++ SYS_GUMBO_LIBS := $(shell $(PKG_CONFIG) --libs gumbo) + endif +- ifeq ($(shell pkg-config --exists harfbuzz && echo yes),yes) +- SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz) +- SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz) ++ ifeq ($(shell $(PKG_CONFIG) --exists harfbuzz && echo yes),yes) ++ SYS_HARFBUZZ_CFLAGS := $(shell $(PKG_CONFIG) --cflags harfbuzz) ++ SYS_HARFBUZZ_LIBS := $(shell $(PKG_CONFIG) --libs harfbuzz) + endif +- ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes) +- SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2) +- SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2) ++ ifeq ($(shell $(PKG_CONFIG) --exists lcms2 && echo yes),yes) ++ SYS_LCMS2_CFLAGS := $(shell $(PKG_CONFIG) --cflags lcms2) ++ SYS_LCMS2_LIBS := $(shell $(PKG_CONFIG) --libs lcms2) + endif +- ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes) +- SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg) +- SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg) ++ ifeq ($(shell $(PKG_CONFIG) --exists libjpeg && echo yes),yes) ++ SYS_LIBJPEG_CFLAGS := $(shell $(PKG_CONFIG) --cflags libjpeg) ++ SYS_LIBJPEG_LIBS := $(shell $(PKG_CONFIG) --libs libjpeg) + endif +- ifeq ($(shell pkg-config --exists libopenjp2 && echo yes),yes) +- SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2) +- SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2) ++ ifeq ($(shell $(PKG_CONFIG) --exists libopenjp2 && echo yes),yes) ++ SYS_OPENJPEG_CFLAGS := $(shell $(PKG_CONFIG) --cflags libopenjp2) ++ SYS_OPENJPEG_LIBS := $(shell $(PKG_CONFIG) --libs libopenjp2) + endif +- ifeq ($(shell pkg-config --exists zlib && echo yes),yes) +- SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib) +- SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib) ++ ifeq ($(shell $(PKG_CONFIG) --exists zlib && echo yes),yes) ++ SYS_ZLIB_CFLAGS := $(shell $(PKG_CONFIG) --cflags zlib) ++ SYS_ZLIB_LIBS := $(shell $(PKG_CONFIG) --libs zlib) + endif + +- HAVE_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes) ++ HAVE_LEPTONICA := $(shell $(PKG_CONFIG) --exists 'lept >= 1.7.4' && echo yes) + ifeq ($(HAVE_LEPTONICA),yes) +- SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept) +- SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept) ++ SYS_LEPTONICA_CFLAGS := $(shell $(PKG_CONFIG) --cflags lept) ++ SYS_LEPTONICA_LIBS := $(shell $(PKG_CONFIG) --libs lept) + endif + +- HAVE_TESSERACT := $(shell pkg-config --exists 'tesseract-ocr >= 4.0.0' && echo yes) ++ HAVE_TESSERACT := $(shell $(PKG_CONFIG) --exists 'tesseract-ocr >= 4.0.0' && echo yes) + ifeq ($(HAVE_TESSERACT),yes) +- SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract) +- SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract) ++ SYS_TESSERACT_CFLAGS := $(shell $(PKG_CONFIG) --cflags tesseract) ++ SYS_TESSERACT_LIBS := $(shell $(PKG_CONFIG) --libs tesseract) + endif + +- HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes) ++ HAVE_SYS_CURL := $(shell $(PKG_CONFIG) --exists libcurl && echo yes) + ifeq ($(HAVE_SYS_CURL),yes) +- SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl) +- SYS_CURL_LIBS := $(shell pkg-config --libs libcurl) ++ SYS_CURL_CFLAGS := $(shell $(PKG_CONFIG) --cflags libcurl) ++ SYS_CURL_LIBS := $(shell $(PKG_CONFIG) --libs libcurl) + endif + + HAVE_GLUT := yes +@@ -183,14 +183,14 @@ else ifeq ($(OS),Linux) + + HAVE_X11 := not-unless-portage-tells-me + ifeq ($(HAVE_X11),yes) +- X11_CFLAGS := $(shell pkg-config --cflags x11 xext) +- X11_LIBS := $(shell pkg-config --libs x11 xext) ++ X11_CFLAGS := $(shell $(PKG_CONFIG) --cflags x11 xext) ++ X11_LIBS := $(shell $(PKG_CONFIG) --libs x11 xext) + endif + + HAVE_LIBCRYPTO := not-unless-portage-tells-me + ifeq ($(HAVE_LIBCRYPTO),yes) +- LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO +- LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto) ++ LIBCRYPTO_CFLAGS := $(shell $(PKG_CONFIG) --cflags libcrypto) -DHAVE_LIBCRYPTO ++ LIBCRYPTO_LIBS := $(shell $(PKG_CONFIG) --libs libcrypto) + endif + + HAVE_PTHREAD := yes diff --git a/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pdf-layer.c b/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pdf-layer.c new file mode 100644 index 000000000000..dc4000b4cde6 --- /dev/null +++ b/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pdf-layer.c @@ -0,0 +1,102 @@ +From b82e9b6d6b46877e5c3763cc3bc641c66fa7eb54 Mon Sep 17 00:00:00 2001 +From: Robin Watts +Date: Thu, 8 Oct 2020 16:15:40 +0100 +Subject: [PATCH] Bug 701297: Harden populate_ui against unexpected repairs. + +We count the number of layers, and allocate space for them in +an array. We then walk the tree reading details of those layers +in. If we hit a problem that causes a repair while reading the +information, the number of layers can magically increase. In +the existing code we run off the end of the array. + +In the new code we watch for hitting the end of the array and +realloc as required. +--- + source/pdf/pdf-layer.c | 32 +++++++++++++++++++++++++------- + 1 file changed, 25 insertions(+), 7 deletions(-) + +diff --git a/source/pdf/pdf-layer.c b/source/pdf/pdf-layer.c +index 177f0c947..b8e9d7cad 100644 +--- a/source/pdf/pdf-layer.c ++++ b/source/pdf/pdf-layer.c +@@ -104,10 +104,27 @@ count_entries(fz_context *ctx, pdf_obj *obj) + } + + static pdf_ocg_ui * +-populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj *order, int depth, pdf_obj *rbgroups, pdf_obj *locked) ++get_ocg_ui(fz_context *ctx, pdf_ocg_descriptor *desc, int fill) ++{ ++ if (fill == desc->num_ui_entries) ++ { ++ /* Number of layers changed while parsing; ++ * probably due to a repair. */ ++ int newsize = desc->num_ui_entries * 2; ++ if (newsize == 0) ++ newsize = 4; /* Arbitrary non-zero */ ++ desc->ui = fz_realloc_array(ctx, desc->ui, newsize, pdf_ocg_ui); ++ desc->num_ui_entries = newsize; ++ } ++ return &desc->ui[fill]; ++} ++ ++static int ++populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, int fill, pdf_obj *order, int depth, pdf_obj *rbgroups, pdf_obj *locked) + { + int len = pdf_array_len(ctx, order); + int i, j; ++ pdf_ocg_ui *ui; + + for (i = 0; i < len; i++) + { +@@ -118,7 +135,7 @@ populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj * + continue; + + fz_try(ctx) +- ui = populate_ui(ctx, desc, ui, o, depth+1, rbgroups, locked); ++ fill = populate_ui(ctx, desc, fill, o, depth+1, rbgroups, locked); + fz_always(ctx) + pdf_unmark_obj(ctx, o); + fz_catch(ctx) +@@ -126,14 +143,14 @@ populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj * + + continue; + } +- ui->depth = depth; + if (pdf_is_string(ctx, o)) + { ++ ui = get_ocg_ui(ctx, desc, fill++); ++ ui->depth = depth; + ui->ocg = -1; + ui->name = pdf_to_str_buf(ctx, o); + ui->button_flags = PDF_LAYER_UI_LABEL; + ui->locked = 1; +- ui++; + continue; + } + +@@ -144,13 +161,14 @@ populate_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_ocg_ui *ui, pdf_obj * + } + if (j == desc->len) + continue; /* OCG not found in main list! Just ignore it */ ++ ui = get_ocg_ui(ctx, desc, fill++); ++ ui->depth = depth; + ui->ocg = j; + ui->name = pdf_dict_get_string(ctx, o, PDF_NAME(Name), NULL); + ui->button_flags = pdf_array_contains(ctx, o, rbgroups) ? PDF_LAYER_UI_RADIOBOX : PDF_LAYER_UI_CHECKBOX; + ui->locked = pdf_array_contains(ctx, o, locked); +- ui++; + } +- return ui; ++ return fill; + } + + static void +@@ -188,7 +206,7 @@ load_ui(fz_context *ctx, pdf_ocg_descriptor *desc, pdf_obj *ocprops, pdf_obj *oc + desc->ui = Memento_label(fz_calloc(ctx, count, sizeof(pdf_ocg_ui)), "pdf_ocg_ui"); + fz_try(ctx) + { +- (void)populate_ui(ctx, desc, desc->ui, order, 0, rbgroups, locked); ++ desc->num_ui_entries = populate_ui(ctx, desc, 0, order, 0, rbgroups, locked); + } + fz_catch(ctx) + { diff --git a/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pixmap.c b/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pixmap.c new file mode 100644 index 000000000000..d19f0593a119 --- /dev/null +++ b/app-text/mupdf/files/mupdf-1.18.0-fix-oob-in-pixmap.c @@ -0,0 +1,41 @@ +From 32e4e8b4bcbacbf92af7c88337efae21986d9603 Mon Sep 17 00:00:00 2001 +From: Robin Watts +Date: Thu, 8 Oct 2020 18:10:28 +0100 +Subject: [PATCH] Bug 702958: Fix overflow in fz_clear_pixmap_with_value. + +--- + source/fitz/pixmap.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/source/fitz/pixmap.c b/source/fitz/pixmap.c +index 66873d214..80d8bb62f 100644 +--- a/source/fitz/pixmap.c ++++ b/source/fitz/pixmap.c +@@ -555,7 +555,8 @@ void + fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value) + { + unsigned char *s; +- int w, h, n, stride, len; ++ int w, h, n; ++ ptrdiff_t stride, len; + int alpha = pix->alpha; + + w = pix->w; +@@ -572,7 +573,7 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value) + + n = pix->n; + stride = pix->stride; +- len = w * n; ++ len = (ptrdiff_t)w * n; + + s = pix->samples; + if (value == 255 || !alpha) +@@ -584,7 +585,7 @@ fz_clear_pixmap_with_value(fz_context *ctx, fz_pixmap *pix, int value) + } + while (h--) + { +- memset(s, value, (unsigned int)len); ++ memset(s, value, len); + s += stride; + } + } -- cgit v1.2.3