diff options
author | Ken Sharp <ken.sharp@artifex.com> | 2023-01-10 09:27:48 +0000 |
---|---|---|
committer | Ken Sharp <ken.sharp@artifex.com> | 2023-01-10 09:29:10 +0000 |
commit | c364af7a228c128f76df10bd4fb9e3ab70e071c1 (patch) | |
tree | db8107f51a7d104118e1c38345e549f9b2f29ae8 /pdf | |
parent | 462efa959c5d7df1dd3fd6ea411522062d1a6c3b (diff) | |
download | ghostpdl-c364af7a228c128f76df10bd4fb9e3ab70e071c1.tar.gz |
GhostPDF - check for failure to open files when building font map
Bug #706315 "`ps2pdf -sFONTPATH=. ...` crashes with SIGSEGV"
When enumerating files in a directory in order to build a font map, we
were not checking the result of sfopen but assuming it would succeed and
then trying to read from it.
On Windows at least, the file may already be open exclusively which
results in sfopen returning a NULL, which causes a seg fault when we
try to use it in sgets().
I'm unable to reproduce this problem on Linux so I can't be certain it
is the same problem as in the report, but it seems likely.
Fixed by simply checking the return value for NULL and ignoring the
file if it is. We obviously can't use it as a font anyway so there's
no harm in ignoring it.
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/pdf_fmap.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pdf/pdf_fmap.c b/pdf/pdf_fmap.c index a33b53884..0d3bc8e36 100644 --- a/pdf/pdf_fmap.c +++ b/pdf/pdf_fmap.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2020-2022 Artifex Software, Inc. +/* Copyright (C) 2020-2023 Artifex Software, Inc. All Rights Reserved. This software is provided AS-IS with no warranty, either express or @@ -677,6 +677,8 @@ static int pdfi_generate_native_fontmap(pdf_context *ctx) continue; sf = sfopen(result, "r", ctx->memory); + if (sf == NULL) + continue; code = sgets(sf, magic, 4, &nread); if (code < 0 || nread < 4) { sfclose(sf); |