Check isDict before calling getDict 2

Resolves: #2189837
This commit is contained in:
Marek Kasik 2023-06-09 16:07:26 +02:00
parent 150094281d
commit 8682069d3f
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,34 @@
--- a/poppler/PDFDoc.cc
+++ b/poppler/PDFDoc.cc
@@ -1757,6 +1757,9 @@ void PDFDoc::replacePageDict(int pageNo,
{
Ref *refPage = getCatalog()->getPageRef(pageNo);
Object page = getXRef()->fetch(*refPage);
+ if (!page.isDict()) {
+ return;
+ }
Dict *pageDict = page.getDict();
pageDict->remove("MediaBoxssdf");
pageDict->remove("MediaBox");
--- a/utils/pdfunite.cc
+++ b/utils/pdfunite.cc
@@ -293,9 +293,18 @@ int main(int argc, char *argv[])
const PDFRectangle *cropBox = nullptr;
if (docs[i]->getCatalog()->getPage(j)->isCropped())
cropBox = docs[i]->getCatalog()->getPage(j)->getCropBox();
- docs[i]->replacePageDict(j, docs[i]->getCatalog()->getPage(j)->getRotate(), docs[i]->getCatalog()->getPage(j)->getMediaBox(), cropBox);
Ref *refPage = docs[i]->getCatalog()->getPageRef(j);
Object page = docs[i]->getXRef()->fetch(*refPage);
+ if (!page.isDict()) {
+ fclose(f);
+ delete yRef;
+ delete countRef;
+ delete outStr;
+ error(errSyntaxError, -1, "PDFDoc::replacePageDict failed.");
+ return -1;
+ } else {
+ docs[i]->replacePageDict(j, docs[i]->getCatalog()->getPage(j)->getRotate(), docs[i]->getCatalog()->getPage(j)->getMediaBox(), cropBox);
+ }
Dict *pageDict = page.getDict();
Object *resDict = docs[i]->getCatalog()->getPage(j)->getResourceDictObject();
if (resDict->isDict()) {

View File

@ -4,7 +4,7 @@
Summary: PDF rendering library Summary: PDF rendering library
Name: poppler Name: poppler
Version: 20.11.0 Version: 20.11.0
Release: 8%{?dist} Release: 9%{?dist}
License: (GPLv2 or GPLv3) and GPLv2+ and LGPLv2+ and MIT License: (GPLv2 or GPLv3) and GPLv2+ and LGPLv2+ and MIT
URL: http://poppler.freedesktop.org/ URL: http://poppler.freedesktop.org/
Source0: http://poppler.freedesktop.org/poppler-%{version}.tar.xz Source0: http://poppler.freedesktop.org/poppler-%{version}.tar.xz
@ -39,6 +39,9 @@ Patch26: poppler-20.11.0-pdfunite-broken-document.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2189811 # https://bugzilla.redhat.com/show_bug.cgi?id=2189811
Patch27: poppler-20.11.0-pdfunite-check-isDict.patch Patch27: poppler-20.11.0-pdfunite-check-isDict.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2189814
Patch28: poppler-20.11.0-check-isDict.patch
BuildRequires: cmake BuildRequires: cmake
BuildRequires: gettext-devel BuildRequires: gettext-devel
BuildRequires: pkgconfig(cairo) BuildRequires: pkgconfig(cairo)
@ -243,6 +246,10 @@ test "$(pkg-config --modversion poppler-splash)" = "%{version}"
%{_mandir}/man1/* %{_mandir}/man1/*
%changelog %changelog
* Fri Jun 9 2023 Marek Kasik <mkasik@redhat.com> - 20.11.0-9
- Check isDict before calling getDict 2
- Resolves: #2189837
* Fri Jun 9 2023 Marek Kasik <mkasik@redhat.com> - 20.11.0-8 * Fri Jun 9 2023 Marek Kasik <mkasik@redhat.com> - 20.11.0-8
- Check isDict before calling getDict - Check isDict before calling getDict
- Resolves: #2189823 - Resolves: #2189823