Fix crash in broken documents when using -dests
Resolves: RHEL-44326
This commit is contained in:
		
							parent
							
								
									d0b61db93e
								
							
						
					
					
						commit
						7d704d8d2b
					
				
							
								
								
									
										102
									
								
								poppler-24.02.0-pdfinfo-dests.patch
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								poppler-24.02.0-pdfinfo-dests.patch
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					From 0554731052d1a97745cb179ab0d45620589dd9c4 Mon Sep 17 00:00:00 2001
 | 
				
			||||||
 | 
					From: Albert Astals Cid <aacid@kde.org>
 | 
				
			||||||
 | 
					Date: Fri, 7 Jun 2024 00:54:55 +0200
 | 
				
			||||||
 | 
					Subject: pdfinfo: Fix crash in broken documents when using -dests
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					diff --git a/utils/pdfinfo.cc b/utils/pdfinfo.cc
 | 
				
			||||||
 | 
					index 5d37ef64..7d569749 100644
 | 
				
			||||||
 | 
					--- a/utils/pdfinfo.cc
 | 
				
			||||||
 | 
					+++ b/utils/pdfinfo.cc
 | 
				
			||||||
 | 
					@@ -15,7 +15,7 @@
 | 
				
			||||||
 | 
					 // under GPL version 2 or later
 | 
				
			||||||
 | 
					 //
 | 
				
			||||||
 | 
					 // Copyright (C) 2006 Dom Lachowicz <cinamod@hotmail.com>
 | 
				
			||||||
 | 
					-// Copyright (C) 2007-2010, 2012, 2016-2022 Albert Astals Cid <aacid@kde.org>
 | 
				
			||||||
 | 
					+// Copyright (C) 2007-2010, 2012, 2016-2022, 2024 Albert Astals Cid <aacid@kde.org>
 | 
				
			||||||
 | 
					 // Copyright (C) 2010 Hib Eris <hib@hiberis.nl>
 | 
				
			||||||
 | 
					 // Copyright (C) 2011 Vittal Aithal <vittal.aithal@cognidox.com>
 | 
				
			||||||
 | 
					 // Copyright (C) 2012, 2013, 2016-2018, 2021 Adrian Johnson <ajohnson@redneon.com>
 | 
				
			||||||
 | 
					@@ -113,16 +113,21 @@ static const ArgDesc argDesc[] = { { "-f", argInt, &firstPage, 0, "first page to
 | 
				
			||||||
 | 
					                                    { "-?", argFlag, &printHelp, 0, "print usage information" },
 | 
				
			||||||
 | 
					                                    {} };
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-static void printTextString(const GooString *s, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					+static void printStdTextString(const std::string &s, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					     char buf[8];
 | 
				
			||||||
 | 
					-    std::vector<Unicode> u = TextStringToUCS4(s->toStr());
 | 
				
			||||||
 | 
					+    const std::vector<Unicode> u = TextStringToUCS4(s);
 | 
				
			||||||
 | 
					     for (const auto &c : u) {
 | 
				
			||||||
 | 
					         int n = uMap->mapUnicode(c, buf, sizeof(buf));
 | 
				
			||||||
 | 
					         fwrite(buf, 1, n, stdout);
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					+static void printTextString(const GooString *s, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					+{
 | 
				
			||||||
 | 
					+    printStdTextString(s->toStr(), uMap);
 | 
				
			||||||
 | 
					+}
 | 
				
			||||||
 | 
					+
 | 
				
			||||||
 | 
					 static void printUCS4String(const Unicode *u, int len, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					     char buf[8];
 | 
				
			||||||
 | 
					@@ -294,11 +299,6 @@ static void printStruct(const StructElement *element, unsigned indent)
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					-struct GooStringCompare
 | 
				
			||||||
 | 
					-{
 | 
				
			||||||
 | 
					-    bool operator()(GooString *lhs, GooString *rhs) const { return lhs->cmp(const_cast<GooString *>(rhs)) < 0; }
 | 
				
			||||||
 | 
					-};
 | 
				
			||||||
 | 
					-
 | 
				
			||||||
 | 
					 static void printLinkDest(const std::unique_ptr<LinkDest> &dest)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					     GooString s;
 | 
				
			||||||
 | 
					@@ -369,29 +369,25 @@ static void printLinkDest(const std::unique_ptr<LinkDest> &dest)
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					 static void printDestinations(PDFDoc *doc, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					 {
 | 
				
			||||||
 | 
					-    std::map<Ref, std::map<GooString *, std::unique_ptr<LinkDest>, GooStringCompare>> map;
 | 
				
			||||||
 | 
					+    std::map<Ref, std::map<std::string, std::unique_ptr<LinkDest>>> map;
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					     int numDests = doc->getCatalog()->numDestNameTree();
 | 
				
			||||||
 | 
					     for (int i = 0; i < numDests; i++) {
 | 
				
			||||||
 | 
					-        GooString *name = new GooString(doc->getCatalog()->getDestNameTreeName(i));
 | 
				
			||||||
 | 
					+        const GooString *name = doc->getCatalog()->getDestNameTreeName(i);
 | 
				
			||||||
 | 
					         std::unique_ptr<LinkDest> dest = doc->getCatalog()->getDestNameTreeDest(i);
 | 
				
			||||||
 | 
					-        if (dest && dest->isPageRef()) {
 | 
				
			||||||
 | 
					+        if (name && dest && dest->isPageRef()) {
 | 
				
			||||||
 | 
					             Ref pageRef = dest->getPageRef();
 | 
				
			||||||
 | 
					-            map[pageRef].insert(std::make_pair(name, std::move(dest)));
 | 
				
			||||||
 | 
					-        } else {
 | 
				
			||||||
 | 
					-            delete name;
 | 
				
			||||||
 | 
					+            map[pageRef].insert(std::make_pair(name->toStr(), std::move(dest)));
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					     numDests = doc->getCatalog()->numDests();
 | 
				
			||||||
 | 
					     for (int i = 0; i < numDests; i++) {
 | 
				
			||||||
 | 
					-        GooString *name = new GooString(doc->getCatalog()->getDestsName(i));
 | 
				
			||||||
 | 
					+        const char *name = doc->getCatalog()->getDestsName(i);
 | 
				
			||||||
 | 
					         std::unique_ptr<LinkDest> dest = doc->getCatalog()->getDestsDest(i);
 | 
				
			||||||
 | 
					-        if (dest && dest->isPageRef()) {
 | 
				
			||||||
 | 
					+        if (name && dest && dest->isPageRef()) {
 | 
				
			||||||
 | 
					             Ref pageRef = dest->getPageRef();
 | 
				
			||||||
 | 
					             map[pageRef].insert(std::make_pair(name, std::move(dest)));
 | 
				
			||||||
 | 
					-        } else {
 | 
				
			||||||
 | 
					-            delete name;
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
 | 
					     }
 | 
				
			||||||
 | 
					 
 | 
				
			||||||
 | 
					@@ -405,9 +401,8 @@ static void printDestinations(PDFDoc *doc, const UnicodeMap *uMap)
 | 
				
			||||||
 | 
					                     printf("%4d ", i);
 | 
				
			||||||
 | 
					                     printLinkDest(it.second);
 | 
				
			||||||
 | 
					                     printf(" \"");
 | 
				
			||||||
 | 
					-                    printTextString(it.first, uMap);
 | 
				
			||||||
 | 
					+                    printStdTextString(it.first, uMap);
 | 
				
			||||||
 | 
					                     printf("\"\n");
 | 
				
			||||||
 | 
					-                    delete it.first;
 | 
				
			||||||
 | 
					                 }
 | 
				
			||||||
 | 
					             }
 | 
				
			||||||
 | 
					         }
 | 
				
			||||||
@ -17,7 +17,7 @@
 | 
				
			|||||||
Summary: PDF rendering library
 | 
					Summary: PDF rendering library
 | 
				
			||||||
Name:    poppler
 | 
					Name:    poppler
 | 
				
			||||||
Version: 24.02.0
 | 
					Version: 24.02.0
 | 
				
			||||||
Release: 3%{?dist}
 | 
					Release: 4%{?dist}
 | 
				
			||||||
License: (GPL-2.0-only OR GPL-3.0-only) AND GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later AND MIT
 | 
					License: (GPL-2.0-only OR GPL-3.0-only) AND GPL-2.0-or-later AND LGPL-2.0-or-later AND LGPL-2.1-or-later 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
 | 
				
			||||||
@ -28,6 +28,9 @@ Patch1:  poppler-0.90.0-position-independent-code.patch
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
Patch3:  poppler-21.01.0-glib-introspection.patch
 | 
					Patch3:  poppler-21.01.0-glib-introspection.patch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# https://issues.redhat.com/browse/RHEL-44326
 | 
				
			||||||
 | 
					Patch4:  poppler-24.02.0-pdfinfo-dests.patch
 | 
				
			||||||
 | 
					
 | 
				
			||||||
BuildRequires: make
 | 
					BuildRequires: make
 | 
				
			||||||
BuildRequires: cmake
 | 
					BuildRequires: cmake
 | 
				
			||||||
BuildRequires: gcc-c++
 | 
					BuildRequires: gcc-c++
 | 
				
			||||||
@ -280,6 +283,10 @@ test "$(pkg-config --modversion poppler-qt6)" = "%{version}"
 | 
				
			|||||||
%{_mandir}/man1/*
 | 
					%{_mandir}/man1/*
 | 
				
			||||||
 | 
					
 | 
				
			||||||
%changelog
 | 
					%changelog
 | 
				
			||||||
 | 
					* Fri Jul 26 2024 Marek Kasik <mkasik@redhat.com> - 24.02.0-4
 | 
				
			||||||
 | 
					- Fix crash in broken documents when using -dests
 | 
				
			||||||
 | 
					- Resolves: RHEL-44326
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 24.02.0-3
 | 
					* Mon Jun 24 2024 Troy Dawson <tdawson@redhat.com> - 24.02.0-3
 | 
				
			||||||
- Bump release for June 2024 mass rebuild
 | 
					- Bump release for June 2024 mass rebuild
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user