Commit 18f376c0 authored by Albert Astals Cid's avatar Albert Astals Cid

FoFiType1::parse: Fix reading past font length

fixes oss-fuzz/8545
parent 19d3993f
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment