poppler/ImageEmbeddingUtils.cc | 4 ++++ 1 file changed, 4 insertions(+)
New commits: commit 9fa129877a47a807f48d15dd6b5cee28734514d7 Author: Albert Astals Cid <[email protected]> Date: Tue Nov 30 00:11:26 2021 +0100 ImageEmbeddingUtils::embed: Return early if filesize < 0 filesize uses lseek which returns -1 on errror, so be sure to return early if that happens diff --git a/poppler/ImageEmbeddingUtils.cc b/poppler/ImageEmbeddingUtils.cc index a3dd5868..eeaa9ad9 100644 --- a/poppler/ImageEmbeddingUtils.cc +++ b/poppler/ImageEmbeddingUtils.cc @@ -358,6 +358,10 @@ Ref embed(XRef *xref, const GooFile &imageFile) { // Load the image file. const Goffset fileSize = imageFile.size(); + if (fileSize < 0) { + error(errIO, -1, "Image file size could not be calculated"); + return Ref::INVALID(); + } uint8_t *fileContent = (uint8_t *)gmalloc(fileSize); const Goffset bytesRead = imageFile.read((char *)fileContent, fileSize, 0); if ((bytesRead != fileSize) || (fileSize < MAX_MAGIC_NUM_SIZE)) {
