summaryrefslogtreecommitdiff
path: root/fofi
diff options
context:
space:
mode:
authorAlbert Astals Cid <aacid@kde.org>2018-05-27 09:29:49 +0200
committerAlbert Astals Cid <aacid@kde.org>2018-05-27 09:29:49 +0200
commit18f376c0dff184851b3ee4c05c40b4ee2c21da8c (patch)
treeddc3dd9ce62ee6b1c1b438776e7d33dd4e3d394d /fofi
parent19d3993f3f40b5113141d5a55acea307c174f1d3 (diff)
FoFiType1::parse: Fix reading past font length
fixes oss-fuzz/8545
Diffstat (limited to 'fofi')
-rw-r--r--fofi/FoFiType1.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/fofi/FoFiType1.cc b/fofi/FoFiType1.cc
index ae9dfc4d..b38c2b4c 100644
--- a/fofi/FoFiType1.cc
+++ b/fofi/FoFiType1.cc
@@ -229,8 +229,10 @@ void FoFiType1::parse() {
if (!name &&
(line + 9 <= (char*)file + len) &&
!strncmp(line, "/FontName", 9)) {
- strncpy(buf, line, 255);
- buf[255] = '\0';
+ const auto availableFile = (char*)file + len - line;
+ const int lineLen = availableFile < 255 ? availableFile : 255;
+ strncpy(buf, line, lineLen);
+ buf[lineLen] = '\0';
if ((p = strchr(buf+9, '/')) &&
(p = strtok_r(p+1, " \t\n\r", &tokptr))) {
name = copyString(p);