diff --git a/ghostscript-9.27-enumerate-all-fonts.patch b/ghostscript-9.27-enumerate-all-fonts.patch new file mode 100644 index 0000000..7e66a98 --- /dev/null +++ b/ghostscript-9.27-enumerate-all-fonts.patch @@ -0,0 +1,94 @@ +diff --git a/base/gp_unix.c b/base/gp_unix.c +index c576566..4165654 100644 +--- a/base/gp_unix.c ++++ b/base/gp_unix.c +@@ -402,42 +402,50 @@ int gp_enumerate_fonts_next(void *enum_state, char **fontname, char **path) + return 0; /* gp_enumerate_fonts_init failed for some reason */ + } + +- if (state->index == state->font_list->nfont) { +- return 0; /* we've run out of fonts */ +- } +- +- /* Bits of the following were borrowed from Red Hat's +- * fontconfig patch for Ghostscript 7 */ +- font = state->font_list->fonts[state->index]; ++ /* We use the loop so we can skip over fonts that return errors */ ++ while(1) { ++ if (state->index == state->font_list->nfont) { ++ return 0; /* we've run out of fonts */ ++ } + +- result = FcPatternGetString (font, FC_FAMILY, 0, &family_fc); +- if (result != FcResultMatch || family_fc == NULL) { +- dmlprintf(state->mem, "DEBUG: FC_FAMILY mismatch\n"); +- return 0; +- } ++ /* Bits of the following were borrowed from Red Hat's ++ * fontconfig patch for Ghostscript 7 */ ++ font = state->font_list->fonts[state->index]; ++ state->index++; ++ ++ /* We do the FC_FILE first because this *should* never fail ++ * and it gives us a string to use in later debug prints ++ */ ++ result = FcPatternGetString (font, FC_FILE, 0, &file_fc); ++ if (result != FcResultMatch || file_fc == NULL) { ++ dmlprintf(state->mem, "DEBUG: FC_FILE mismatch\n"); ++ continue; ++ } + +- result = FcPatternGetString (font, FC_FILE, 0, &file_fc); +- if (result != FcResultMatch || file_fc == NULL) { +- dmlprintf(state->mem, "DEBUG: FC_FILE mismatch\n"); +- return 0; +- } ++ result = FcPatternGetString (font, FC_FAMILY, 0, &family_fc); ++ if (result != FcResultMatch || family_fc == NULL) { ++ dmlprintf1(state->mem, "DEBUG: FC_FAMILY mismatch in %s\n", (char *)file_fc); ++ continue; ++ } + +- result = FcPatternGetBool (font, FC_OUTLINE, 0, &outline_fc); +- if (result != FcResultMatch) { +- dmlprintf1(state->mem, "DEBUG: FC_OUTLINE failed to match on %s\n", (char*)family_fc); +- return 0; +- } ++ result = FcPatternGetBool (font, FC_OUTLINE, 0, &outline_fc); ++ if (result != FcResultMatch) { ++ dmlprintf2(state->mem, "DEBUG: FC_OUTLINE failed to match on %s in %s\n", (char*)family_fc, (char *)file_fc); ++ continue; ++ } + +- result = FcPatternGetInteger (font, FC_SLANT, 0, &slant_fc); +- if (result != FcResultMatch) { +- dmlprintf(state->mem, "DEBUG: FC_SLANT didn't match\n"); +- return 0; +- } ++ result = FcPatternGetInteger (font, FC_SLANT, 0, &slant_fc); ++ if (result != FcResultMatch) { ++ dmlprintf1(state->mem, "DEBUG: FC_SLANT didn't match in %s\n", (char *)file_fc); ++ continue; ++ } + +- result = FcPatternGetInteger (font, FC_WEIGHT, 0, &weight_fc); +- if (result != FcResultMatch) { +- dmlprintf(state->mem, "DEBUG: FC_WEIGHT didn't match\n"); +- return 0; ++ result = FcPatternGetInteger (font, FC_WEIGHT, 0, &weight_fc); ++ if (result != FcResultMatch) { ++ dmlprintf1(state->mem, "DEBUG: FC_WEIGHT didn't match in %s\n", (char *)file_fc); ++ continue; ++ } ++ break; + } + + /* Gross hack to work around Fontconfig's inability to tell +@@ -450,7 +458,6 @@ int gp_enumerate_fonts_next(void *enum_state, char **fontname, char **path) + /* return the font path straight out of fontconfig */ + *path = (char*)file_fc; + +- state->index ++; + return 1; + #else + return 0; diff --git a/ghostscript.spec b/ghostscript.spec index 4b0b8cd..10339a6 100644 --- a/ghostscript.spec +++ b/ghostscript.spec @@ -43,7 +43,7 @@ Name: ghostscript Summary: Interpreter for PostScript language & PDF Version: 9.27 -Release: 2%{?dist} +Release: 3%{?dist} License: AGPLv3+ @@ -97,6 +97,7 @@ Patch000: ghostscript-cve-2019-10216.patch Patch001: ghostscript-cve-2019-14811-14812-14813.patch Patch002: ghostscript-cve-2019-14817.patch Patch003: ghostscript-cve-2019-14869.patch +Patch004: ghostscript-9.27-enumerate-all-fonts.patch # Downstream patches -- these should be always included when doing rebase: @@ -462,6 +463,9 @@ done # ============================================================================= %changelog +* Thu Mar 12 2020 Zdenek Dohnal - 9.27-3 +- 1722900 - ghostscript stops enumerating fonts on the first font which fontconfig returns mismatch for + * Thu Nov 14 2019 Zdenek Dohnal - 9.27-2 - 1772486 - ghostscript: -dSAFER escape in .charkeys (701841)