ghostscript/0001-Bug-701969-Fix-fontconfig-path-permissions-handling.patch
Zdenek Dohnal 5e7ab74206 9.50
2020-03-12 14:35:34 +01:00

59 lines
2.1 KiB
Diff

From 53ab3ecee8a60d412c2bf1406340bf9cb228e106 Mon Sep 17 00:00:00 2001
From: Chris Liddell <chris.liddell@artifex.com>
Date: Wed, 4 Dec 2019 12:23:02 +0000
Subject: [PATCH] Bug 701969: Fix fontconfig path permissions handling
The paths from fontconfig to be added to the permit file reading list was not
having the trailing directory separator added to indicate we want to allow
the directory to be read.
Also, tweak the path/filename splitting (for the permit file read list) when
parsing the cidfmap so it matches the improved version in gs_fonts.ps
---
Resource/Init/gs_cidfm.ps | 4 ++--
base/gp_unix.c | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/Resource/Init/gs_cidfm.ps b/Resource/Init/gs_cidfm.ps
index cd9ed883f..e123bfc1c 100644
--- a/Resource/Init/gs_cidfm.ps
+++ b/Resource/Init/gs_cidfm.ps
@@ -141,7 +141,7 @@ currentdict end def
% <dir.../base.extn> .basename <dir>
/.splitdirname {
(/) rsearch { //true } { (\\) rsearch } ifelse
- {3 -2 roll pop pop //true}{//false} ifelse
+ {exch concatstrings exch pop //true}{//false} ifelse
} bind def
% <file> .addcidfmappath -
@@ -214,7 +214,7 @@ currentdict end def
} loop
} forall
currentdict end
- {exch pop (/) concatstrings /PermitFileReading exch .addcontrolpath} forall
+ {exch pop /PermitFileReading exch .addcontrolpath} forall
% Checks for vicious substitution cycles.
dup length dict copy % <<map>>
diff --git a/base/gp_unix.c b/base/gp_unix.c
index 6d2b8b163..ecf0e8a63 100644
--- a/base/gp_unix.c
+++ b/base/gp_unix.c
@@ -356,7 +356,11 @@ void *gp_enumerate_fonts_init(gs_memory_t *mem)
*/
code = 0;
while ((dirstr = FcStrListNext(fdirlist)) != NULL && code >= 0) {
- code = gs_add_control_path(mem, gs_permit_file_reading, (char *)dirstr);
+ char dirstr2[gp_file_name_sizeof];
+ dirstr2[0] = '\0';
+ strncat(dirstr2, (char *)dirstr, gp_file_name_sizeof - 1);
+ strncat(dirstr2, "/", gp_file_name_sizeof);
+ code = gs_add_control_path(mem, gs_permit_file_reading, (char *)dirstr2);
}
FcStrListDone(fdirlist);
if (code < 0) {
--
2.24.1