Merge pull request #4473 from Snuffleupagus/bug-866395-partial
Prevent infinite loop in CFFParser_parseHeader
This commit is contained in:
commit
59829bb49f
@ -5628,12 +5628,17 @@ var CFFParser = (function CFFParserClosure() {
|
|||||||
},
|
},
|
||||||
parseHeader: function CFFParser_parseHeader() {
|
parseHeader: function CFFParser_parseHeader() {
|
||||||
var bytes = this.bytes;
|
var bytes = this.bytes;
|
||||||
|
var bytesLength = bytes.length;
|
||||||
var offset = 0;
|
var offset = 0;
|
||||||
|
|
||||||
while (bytes[offset] != 1)
|
// Prevent an infinite loop, by checking that the offset is within the
|
||||||
|
// bounds of the bytes array. Necessary in empty, or invalid, font files.
|
||||||
|
while (offset < bytesLength && bytes[offset] !== 1) {
|
||||||
++offset;
|
++offset;
|
||||||
|
}
|
||||||
if (offset !== 0) {
|
if (offset >= bytesLength) {
|
||||||
|
error('Invalid CFF header');
|
||||||
|
} else if (offset !== 0) {
|
||||||
info('cff data is shifted');
|
info('cff data is shifted');
|
||||||
bytes = bytes.subarray(offset);
|
bytes = bytes.subarray(offset);
|
||||||
this.bytes = bytes;
|
this.bytes = bytes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user