Update to 0.9.7

epel9
Sandro Mani 4 years ago
parent 81d1a4835b
commit a1a7386ad9

1
.gitignore vendored

@ -6,3 +6,4 @@ podofo-0.8.1.tar.gz
/podofo-0.9.4.tar.gz /podofo-0.9.4.tar.gz
/podofo-0.9.5.tar.gz /podofo-0.9.5.tar.gz
/podofo-0.9.6.tar.gz /podofo-0.9.6.tar.gz
/podofo-0.9.7.tar.gz

@ -1,7 +1,7 @@
diff -rupN podofo-0.9.6/CMakeLists.txt podofo-0.9.6-new/CMakeLists.txt diff -rupN --no-dereference podofo-0.9.7/CMakeLists.txt podofo-0.9.7-new/CMakeLists.txt
--- podofo-0.9.6/CMakeLists.txt 2018-07-08 12:33:27.000000000 +0200 --- podofo-0.9.7/CMakeLists.txt 2021-01-05 17:56:54.000000000 +0100
+++ podofo-0.9.6-new/CMakeLists.txt 2019-03-13 23:15:12.088138762 +0100 +++ podofo-0.9.7-new/CMakeLists.txt 2021-01-09 20:24:45.274935094 +0100
@@ -398,8 +398,8 @@ ENDIF(NOT PODOFO_BUILD_LIB_ONLY) @@ -407,8 +407,8 @@ ENDIF(NOT PODOFO_BUILD_LIB_ONLY)
FIND_PACKAGE(OpenSSL) FIND_PACKAGE(OpenSSL)
@ -12,10 +12,10 @@ diff -rupN podofo-0.9.6/CMakeLists.txt podofo-0.9.6-new/CMakeLists.txt
FIND_PACKAGE(LIBSTLPORT) FIND_PACKAGE(LIBSTLPORT)
SET(stlport_libraries_if_use_stlport) SET(stlport_libraries_if_use_stlport)
@@ -478,7 +478,7 @@ INCLUDE_DIRECTORIES(BEFORE # before tool @@ -487,7 +487,7 @@ INCLUDE_DIRECTORIES(BEFORE # before tool
INCLUDE_DIRECTORIES( INCLUDE_DIRECTORIES(
${PoDoFo_SOURCE_DIR}/src ${PoDoFo_SOURCE_DIR}/src/podofo
- ${FREETYPE_INCLUDE_DIR} - ${FREETYPE_INCLUDE_DIR}
+ ${FREETYPE_INCLUDE_DIRS} + ${FREETYPE_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR}

@ -1,6 +1,6 @@
Name: podofo Name: podofo
Version: 0.9.6 Version: 0.9.7
Release: 13%{?dist} Release: 1%{?dist}
Summary: Tools and libraries to work with the PDF file format Summary: Tools and libraries to work with the PDF file format
# The library is licensed under the LGPL. # The library is licensed under the LGPL.
@ -11,48 +11,13 @@ URL: http://podofo.sourceforge.net
Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.gz
# Fix failure to detect FreeType # Fix failure to detect FreeType
Patch0: podofo-0.9.4-freetype.patch Patch0: podofo-0.9.4-freetype.patch
# Don't attempt to copy non-existing testdata dir
Patch1: podofo_tests.patch
# Fix pkg-config file
Patch2: podofo_pkgconfig.patch
# Backport patch for CVE-2018-5783
# https://sourceforge.net/p/podofo/code/1949
Patch10: podofo_CVE-2018-5783.patch
# Backport patch for CVE-2018-11254
# https://sourceforge.net/p/podofo/code/1941
Patch11: podofo_CVE-2018-11254.patch
# Backport patch for CVE-2018-11255
# https://sourceforge.net/p/podofo/code/1952
Patch12: podofo_CVE-2018-11255.patch
# Backport patch for CVE-2018-11256
# https://sourceforge.net/p/podofo/code/1938
Patch13: podofo_CVE-2018-11256.patch
# Backport patch for CVE-2018-12982
# https://sourceforge.net/p/podofo/code/1948
Patch14: podofo_CVE-2018-12982.patch
# Backport patch for CVE-2018-14320
# https://sourceforge.net/p/podofo/code/1953
Patch15: podofo_CVE-2018-14320.patch
# Backport patch for CVE-2018-19532
# https://sourceforge.net/p/podofo/code/1950
Patch16: podofo_CVE-2018-19532.patch
# Backport patch for CVE-2018-20751
# https://sourceforge.net/p/podofo/code/1954
Patch17: podofo_CVE-2018-20751.patch
# Backport patch for CVE-2019-9199
# https://sourceforge.net/p/podofo/code/1971/
Patch18: podofo_CVE-2019-9199.patch
# Backport patch for CVE-2019-9687
# https://sourceforge.net/p/podofo/code/1969
Patch19: podofo_CVE-2019-9687.patch
# Downstream patch for CVE-2019-20093 # Downstream patch for CVE-2019-20093
# https://sourceforge.net/p/podofo/tickets/75/ # https://sourceforge.net/p/podofo/tickets/75/
Patch20: podofo_CVE-2019-20093.patch Patch20: podofo_CVE-2019-20093.patch
# Proposed patch for CVE-2018-12983 # Proposed patch for CVE-2018-12983
# https://sourceforge.net/p/podofo/tickets/23/ # https://sourceforge.net/p/podofo/tickets/23/
Patch21: podofo_CVE-2018-12983.diff Patch21: podofo_CVE-2018-12983.patch
# https://sourceforge.net/p/podofo/tickets/101/ # https://sourceforge.net/p/podofo/tickets/101/
Patch22: podofo_maxbytes.patch Patch22: podofo_maxbytes.patch
@ -152,7 +117,7 @@ find doc/html -exec touch -r %{SOURCE0} {} \;
%files libs %files libs
%doc AUTHORS ChangeLog FAQ.html README.html TODO %doc AUTHORS ChangeLog FAQ.html README.html TODO
%license COPYING.LIB COPYING.exception %license COPYING.LIB COPYING.exception
%{_libdir}/*.so.0.9.6 %{_libdir}/*.so.0.9.7
%files devel %files devel
%doc doc/html examples %doc doc/html examples
@ -162,6 +127,9 @@ find doc/html -exec touch -r %{SOURCE0} {} \;
%changelog %changelog
* Sat Jan 09 2021 Sandro Mani <manisandro@gmail.com> - 0.9.7-1
- Update to 0.9.7
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.6-13 * Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.9.6-13
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

File diff suppressed because it is too large Load Diff

@ -1,17 +0,0 @@
diff -rupN podofo-0.9.6/src/doc/PdfPage.cpp podofo-0.9.6-new/src/doc/PdfPage.cpp
--- podofo-0.9.6/src/doc/PdfPage.cpp 2018-03-11 20:40:59.000000000 +0100
+++ podofo-0.9.6-new/src/doc/PdfPage.cpp 2019-03-13 23:15:12.206138732 +0100
@@ -595,6 +595,13 @@ unsigned int PdfPage::GetPageNumber() co
while( it != kids.end() && (*it).GetReference() != ref )
{
PdfObject* pNode = this->GetObject()->GetOwner()->GetObject( (*it).GetReference() );
+ if (!pNode)
+ {
+ std::ostringstream oss;
+ oss << "Object " << (*it).GetReference().ToString() << " not found from Kids array "
+ << pKids->Reference().ToString();
+ PODOFO_RAISE_ERROR_INFO( ePdfError_NoObject, oss.str() );
+ }
if( pNode->GetDictionary().GetKey( PdfName::KeyType ) != NULL
&& pNode->GetDictionary().GetKey( PdfName::KeyType )->GetName() == PdfName( "Pages" ) )

@ -1,16 +0,0 @@
diff -rupN podofo-0.9.6/src/doc/PdfDocument.cpp podofo-0.9.6-new/src/doc/PdfDocument.cpp
--- podofo-0.9.6/src/doc/PdfDocument.cpp 2016-11-18 20:08:56.000000000 +0100
+++ podofo-0.9.6-new/src/doc/PdfDocument.cpp 2019-03-13 23:15:12.234138725 +0100
@@ -325,6 +325,12 @@ const PdfDocument & PdfDocument::Append(
for(int i=0;i<rDoc.GetPageCount();i++ )
{
PdfPage* pPage = rDoc.GetPage( i );
+ if (NULL == pPage)
+ {
+ std::ostringstream oss;
+ oss << "No page " << i << " (the first is 0) found.";
+ PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, oss.str() );
+ }
PdfObject* pObj = m_vecObjects.GetObject( PdfReference( pPage->GetObject()->Reference().ObjectNumber() + difference, pPage->GetObject()->Reference().GenerationNumber() ) );
if( pObj->IsDictionary() && pObj->GetDictionary().HasKey( "Parent" ) )
pObj->GetDictionary().RemoveKey( "Parent" );

@ -1,75 +0,0 @@
diff -rupN podofo-0.9.6/src/base/PdfDictionary.h podofo-0.9.6-new/src/base/PdfDictionary.h
--- podofo-0.9.6/src/base/PdfDictionary.h 2018-06-11 01:46:56.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfDictionary.h 2019-03-13 23:15:12.260138718 +0100
@@ -180,6 +180,21 @@ class PODOFO_API PdfDictionary : public
*/
PdfObject* GetKey( const PdfName & key );
+ /** Get the key's value out of the dictionary.
+ *
+ * The returned value is a reference to the internal object in the dictionary
+ * so it MUST not be deleted. If the key is not found, this throws a PdfError
+ * exception with error code ePdfError_NoObject, instead of returning.
+ * This is intended to make code more readable by sparing (especially multiple)
+ * NULL checks.
+ *
+ * \param key look for the key named key in the dictionary
+ *
+ * \returns reference to the found value (never 0).
+ * \throws PdfError(ePdfError_NoObject).
+ */
+ inline const PdfObject& MustGetKey( const PdfName & key ) const;
+
pdf_int64 GetKeyAsLong( const PdfName & key, pdf_int64 lDefault = 0 ) const;
double GetKeyAsReal( const PdfName & key, double dDefault = 0.0 ) const;
@@ -305,6 +320,18 @@ TKeyMap & PdfDictionary::GetKeys()
// -----------------------------------------------------
//
// -----------------------------------------------------
+
+const PdfObject& PdfDictionary::MustGetKey( const PdfName & key ) const
+{
+ const PdfObject* obj = GetKey( key );
+ if (!obj)
+ PODOFO_RAISE_ERROR( ePdfError_NoObject );
+ return *obj;
+}
+
+// -----------------------------------------------------
+//
+// -----------------------------------------------------
void PdfDictionary::Write( PdfOutputDevice* pDevice, EPdfWriteMode eWriteMode, const PdfEncrypt* pEncrypt ) const
{
this->Write( pDevice, eWriteMode, pEncrypt, PdfName::KeyNull );
diff -rupN podofo-0.9.6/src/base/PdfEncrypt.cpp podofo-0.9.6-new/src/base/PdfEncrypt.cpp
--- podofo-0.9.6/src/base/PdfEncrypt.cpp 2017-02-26 21:48:19.000000000 +0100
+++ podofo-0.9.6-new/src/base/PdfEncrypt.cpp 2019-03-13 23:15:12.260138718 +0100
@@ -561,13 +561,13 @@ PdfEncrypt* PdfEncrypt::CreatePdfEncrypt
try {
PdfString sTmp;
- lV = static_cast<long>(pObject->GetDictionary().GetKey( PdfName("V") )->GetNumber());
- rValue = static_cast<int>(pObject->GetDictionary().GetKey( PdfName("R") )->GetNumber());
+ lV = static_cast<long>(pObject->GetDictionary().MustGetKey( PdfName("V") ).GetNumber());
+ rValue = static_cast<int>( pObject->GetDictionary().MustGetKey( PdfName("R") ).GetNumber());
- pValue = static_cast<int>(pObject->GetDictionary().GetKey( PdfName("P") )->GetNumber());
+ pValue = static_cast<int>( pObject->GetDictionary().MustGetKey( PdfName("P") ).GetNumber());
- oValue = pObject->GetDictionary().GetKey( PdfName("O") )->GetString();
- uValue = pObject->GetDictionary().GetKey( PdfName("U") )->GetString();
+ oValue = pObject->GetDictionary().MustGetKey( PdfName("O") ).GetString();
+ uValue = pObject->GetDictionary().MustGetKey( PdfName("U") ).GetString();
if( pObject->GetDictionary().HasKey( PdfName("Length") ) )
{
@@ -593,7 +593,7 @@ PdfEncrypt* PdfEncrypt::CreatePdfEncrypt
}
}
} catch( PdfError & e ) {
- e.AddToCallstack( __FILE__, __LINE__, "Invalid key in encryption dictionary" );
+ e.AddToCallstack( __FILE__, __LINE__, "Invalid or missing key in encryption dictionary" );
throw e;
}

@ -1,7 +1,7 @@
diff -rupN --no-dereference podofo-0.9.6/src/base/PdfEncrypt.cpp podofo-0.9.6-new/src/base/PdfEncrypt.cpp diff -rupN --no-dereference podofo-0.9.7/src/podofo/base/PdfEncrypt.cpp podofo-0.9.7-new/src/podofo/base/PdfEncrypt.cpp
--- podofo-0.9.6/src/base/PdfEncrypt.cpp 2020-07-02 10:27:57.484446311 +0200 --- podofo-0.9.7/src/podofo/base/PdfEncrypt.cpp 2019-01-15 14:04:40.000000000 +0100
+++ podofo-0.9.6-new/src/base/PdfEncrypt.cpp 2020-07-02 10:27:57.694448247 +0200 +++ podofo-0.9.7-new/src/podofo/base/PdfEncrypt.cpp 2021-01-09 20:24:45.328924249 +0100
@@ -607,6 +607,12 @@ PdfEncrypt* PdfEncrypt::CreatePdfEncrypt @@ -615,6 +615,12 @@ PdfEncrypt* PdfEncrypt::CreatePdfEncrypt
&& PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_RC4V2 ) ) && PdfEncrypt::IsEncryptionEnabled( ePdfEncryptAlgorithm_RC4V2 ) )
{ {
// [Alexey] - lLength is pdf_int64. Please make changes in encryption algorithms // [Alexey] - lLength is pdf_int64. Please make changes in encryption algorithms

@ -1,90 +0,0 @@
diff -rupN podofo-0.9.6/src/base/PdfEncoding.cpp podofo-0.9.6-new/src/base/PdfEncoding.cpp
--- podofo-0.9.6/src/base/PdfEncoding.cpp 2017-04-28 18:49:01.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfEncoding.cpp 2019-03-13 23:15:12.294138709 +0100
@@ -285,6 +285,12 @@ void PdfEncoding::ParseToUnicode()
if (strcmp (streamToken, "beginbfrange") == 0)
{
+ // need 2 entries - one to pop() and one for top()
+ if ( stkToken.size() < 2 )
+ {
+ PODOFO_RAISE_ERROR_INFO(ePdfError_InvalidStream, "CMap missing object number before beginbfrange");
+ }
+
i = loop = 0;
in_beginbfrange = 1;
stkToken.pop ();
@@ -301,6 +307,12 @@ void PdfEncoding::ParseToUnicode()
if (strcmp (streamToken, "beginbfchar") == 0)
{
+ // need 2 entries - one to pop() and one for top()
+ if ( stkToken.size() < 2 )
+ {
+ PODOFO_RAISE_ERROR_INFO(ePdfError_InvalidStream, "CMap missing object number before beginbfchar");
+ }
+
i = loop = 0;
in_beginbfchar = 1;
stkToken.pop ();
diff -rupN podofo-0.9.6/test/unit/EncodingTest.cpp podofo-0.9.6-new/test/unit/EncodingTest.cpp
--- podofo-0.9.6/test/unit/EncodingTest.cpp 2018-03-10 18:01:08.000000000 +0100
+++ podofo-0.9.6-new/test/unit/EncodingTest.cpp 2019-03-13 23:15:12.294138709 +0100
@@ -359,6 +359,57 @@ void EncodingTest::testToUnicodeParse()
#endif
CPPUNIT_ASSERT_EQUAL( expects, unicodeStr[ii] );
}
+
+ const char* toUnicodeInvalidTests[] =
+ {
+ // missing object numbers
+ "beginbfrange\n",
+ "beginbfchar\n",
+
+ // invalid hex digits
+ "2 beginbfrange <WXYZ> endbfrange\n",
+ "2 beginbfrange <-123> endbfrange\n",
+ "2 beginbfrange <<00>> endbfrange\n",
+
+ // missing hex digits
+ "2 beginbfrange <> endbfrange\n",
+
+ // empty array
+ "2 beginbfrange [] endbfrange\n",
+
+ nullptr
+ };
+
+ for ( size_t i = 0 ; toUnicodeInvalidTests[i] != nullptr ; ++i )
+ {
+ try
+ {
+ PdfVecObjects vecInvalid;
+ PdfObject *strmInvalidObject;
+
+ vec.SetAutoDelete( true );
+
+ strmInvalidObject = vecInvalid.CreateObject( PdfVariant( PdfDictionary() ) );
+ strmInvalidObject->GetStream()->Set( toUnicodeInvalidTests[i], strlen( toUnicodeInvalidTests[i] ) );
+
+ PdfIdentityEncoding encodingTestInvalid(0x0001, 0x000F, true, strmInvalidObject);
+
+ PdfString unicodeStringTestInvalid = encoding.ConvertToUnicode( PdfString( encodedStr ), NULL );
+
+ // exception not thrown - should never get here
+ // TODO not all invalid input throws an exception (e.g. no hex digits in <WXYZ>)
+ //CPPUNIT_ASSERT( false );
+ }
+ catch ( PoDoFo::PdfError& error )
+ {
+ // parsing every invalid test string should throw an exception
+ CPPUNIT_ASSERT( true );
+ }
+ catch( std::exception& ex )
+ {
+ CPPUNIT_FAIL( "Unexpected exception type" );
+ }
+ }
}
bool EncodingTest::outofRangeHelper( PdfEncoding* pEncoding, std::string & rMsg, const char* pszName )

@ -1,18 +0,0 @@
diff -rupN podofo-0.9.6/tools/podofoimpose/pdftranslator.cpp podofo-0.9.6-new/tools/podofoimpose/pdftranslator.cpp
--- podofo-0.9.6/tools/podofoimpose/pdftranslator.cpp 2016-11-18 20:08:56.000000000 +0100
+++ podofo-0.9.6-new/tools/podofoimpose/pdftranslator.cpp 2019-03-13 23:15:12.323138702 +0100
@@ -256,7 +256,13 @@ namespace PoDoFo
PdfPage * page = sourceDoc->GetPage ( i );
PdfMemoryOutputStream outMemStream ( 1 );
- PdfXObject *xobj = new PdfXObject ( page->GetMediaBox(), targetDoc );
+ if (!page) // Fix issue #32
+ {
+ std::ostringstream oss;
+ oss << "Page " << i << " (0-based) of " << pcount << " in source doc not found!";
+ PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, oss.str() );
+ }
+ PdfXObject *xobj = new PdfXObject ( page->GetMediaBox(), targetDoc );
if ( page->GetContents()->HasStream() )
{
page->GetContents()->GetStream()->GetFilteredCopy ( &outMemStream );

@ -1,15 +0,0 @@
diff -rupN podofo-0.9.6/tools/podofocrop/podofocrop.cpp podofo-0.9.6-new/tools/podofocrop/podofocrop.cpp
--- podofo-0.9.6/tools/podofocrop/podofocrop.cpp 2016-11-18 20:08:56.000000000 +0100
+++ podofo-0.9.6-new/tools/podofocrop/podofocrop.cpp 2019-03-13 23:15:12.352138694 +0100
@@ -61,6 +61,11 @@ void crop_page( PdfPage* pPage, const Pd
rCropBox.GetHeight());
*/
rCropBox.ToVariant( var );
+ if (!pPage)
+ {
+ PODOFO_RAISE_ERROR_INFO( ePdfError_InvalidHandle,
+ "crop_page: No page pointer given" );
+ }
pPage->GetObject()->GetDictionary().AddKey( PdfName("MediaBox"), var );
}

@ -1,106 +0,0 @@
diff -rupN podofo-0.9.6/src/base/PdfCompilerCompat.h podofo-0.9.6-new/src/base/PdfCompilerCompat.h
--- podofo-0.9.6/src/base/PdfCompilerCompat.h 2017-10-27 08:38:19.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfCompilerCompat.h 2019-03-13 23:15:12.143138748 +0100
@@ -184,12 +184,15 @@ namespace PoDoFo {
#if defined(_MSC_VER)
# define PDF_FORMAT_INT64 "I64d"
# define PDF_FORMAT_UINT64 "I64u"
+# define PDF_SIZE_FORMAT "Iu"
#elif defined(SZ_INT64) && defined(SZ_LONG) && SZ_INT64 == SZ_LONG
# define PDF_FORMAT_INT64 "ld"
# define PDF_FORMAT_UINT64 "lu"
+# define PDF_SIZE_FORMAT "zu"
#else
# define PDF_FORMAT_INT64 "lld"
# define PDF_FORMAT_UINT64 "llu"
+# define PDF_SIZE_FORMAT "zu"
#endif
diff -rupN podofo-0.9.6/src/base/PdfVecObjects.cpp podofo-0.9.6-new/src/base/PdfVecObjects.cpp
--- podofo-0.9.6/src/base/PdfVecObjects.cpp 2017-06-04 15:28:32.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfVecObjects.cpp 2019-03-13 23:15:12.144138748 +0100
@@ -100,6 +100,10 @@ private:
const PdfReference m_ref;
};
+// This is static, IMHO (mabri) different values per-instance could cause confusion.
+// It has to be defined here because of the one-definition rule.
+size_t PdfVecObjects::m_nMaxReserveSize = static_cast<size_t>(8388607); // cf. Table C.1 in section C.2 of PDF32000_2008.pdf
+
PdfVecObjects::PdfVecObjects()
: m_bAutoDelete( false ), m_bCanReuseObjectNumbers( true ), m_nObjectCount( 1 ), m_bSorted( true ), m_pDocument( NULL ), m_pStreamFactory( NULL )
{
diff -rupN podofo-0.9.6/src/base/PdfVecObjects.h podofo-0.9.6-new/src/base/PdfVecObjects.h
--- podofo-0.9.6/src/base/PdfVecObjects.h 2016-11-14 17:21:06.000000000 +0100
+++ podofo-0.9.6-new/src/base/PdfVecObjects.h 2019-03-13 23:15:12.144138748 +0100
@@ -414,6 +414,25 @@ class PODOFO_API PdfVecObjects {
inline PdfObject* GetBack();
/**
+ * Set the maximum number of elements Reserve() will work for (to fix
+ * CVE-2018-5783) which is called with a value from the PDF in the parser.
+ * The default is from Table C.1 in section C.2 of PDF32000_2008.pdf
+ * (PDF 1.7 standard free version).
+ * This sets a static variable, so don't use from multiple threads
+ * (without proper locking).
+ * \param size Number of elements to allow to be reserved
+ */
+ void SetMaxReserveSize(size_t size);
+
+ /**
+ * Gets the maximum number of elements Reserve() will work for (to fix
+ * CVE-2018-5783) which is called with a value from the PDF in the parser.
+ * The default is from Table C.1 in section C.2 of PDF32000_2008.pdf
+ * (PDF 1.7 standard free version): 8388607.
+ */
+ size_t GetMaxReserveSize() const;
+
+ /**
* Deletes all objects that are not references by other objects
* besides the trailer (which references the root dictionary, which in
* turn should reference all other objects).
@@ -480,6 +499,7 @@ class PODOFO_API PdfVecObjects {
StreamFactory* m_pStreamFactory;
std::string m_sSubsetPrefix; ///< Prefix for BaseFont and FontName of subsetted font
+ static size_t m_nMaxReserveSize;
};
@@ -494,9 +514,34 @@ inline size_t PdfVecObjects::GetSize() c
// -----------------------------------------------------
//
// -----------------------------------------------------
+inline void PdfVecObjects::SetMaxReserveSize(size_t size)
+{
+ m_nMaxReserveSize = size;
+}
+
+// -----------------------------------------------------
+//
+// -----------------------------------------------------
+inline size_t PdfVecObjects::GetMaxReserveSize() const
+{
+ return m_nMaxReserveSize;
+}
+
+// -----------------------------------------------------
+//
+// -----------------------------------------------------
inline void PdfVecObjects::Reserve( size_t size )
{
- m_vector.reserve( size );
+ if( size <= m_nMaxReserveSize ) // Fix CVE-2018-5783
+ {
+ m_vector.reserve( size );
+ }
+ else
+ {
+ PdfError::DebugMessage( "Call to PdfVecObjects::Reserve with %"
+ PDF_SIZE_FORMAT" is over allowed limit of %"
+ PDF_SIZE_FORMAT".\n", size, m_nMaxReserveSize );
+ }
}
// -----------------------------------------------------

@ -1,6 +1,6 @@
diff -wrupN podofo-0.9.6/tools/podofoimgextract/ImageExtractor.cpp podofo-0.9.6-new/tools/podofoimgextract/ImageExtractor.cpp diff -rupN --no-dereference podofo-0.9.7/tools/podofoimgextract/ImageExtractor.cpp podofo-0.9.7-new/tools/podofoimgextract/ImageExtractor.cpp
--- podofo-0.9.6/tools/podofoimgextract/ImageExtractor.cpp 2018-02-25 12:48:38.000000000 +0100 --- podofo-0.9.7/tools/podofoimgextract/ImageExtractor.cpp 2018-02-25 12:48:38.000000000 +0100
+++ podofo-0.9.6-new/tools/podofoimgextract/ImageExtractor.cpp 2020-01-17 19:43:48.619699851 +0100 +++ podofo-0.9.7-new/tools/podofoimgextract/ImageExtractor.cpp 2021-01-09 20:24:45.300929872 +0100
@@ -117,6 +117,11 @@ void ImageExtractor::ExtractImage( PdfOb @@ -117,6 +117,11 @@ void ImageExtractor::ExtractImage( PdfOb
//long lBitsPerComponent = pObject->GetDictionary().GetKey( PdfName("BitsPerComponent" ) )->GetNumber(); //long lBitsPerComponent = pObject->GetDictionary().GetKey( PdfName("BitsPerComponent" ) )->GetNumber();
// TODO: Handle colorspaces // TODO: Handle colorspaces

@ -1,17 +0,0 @@
diff -rupN podofo-0.9.6/tools/podofoimpose/pdftranslator.cpp podofo-0.9.6-new/tools/podofoimpose/pdftranslator.cpp
--- podofo-0.9.6/tools/podofoimpose/pdftranslator.cpp 2019-03-13 23:15:12.348138695 +0100
+++ podofo-0.9.6-new/tools/podofoimpose/pdftranslator.cpp 2019-03-13 23:15:12.381138687 +0100
@@ -148,7 +148,12 @@ namespace PoDoFo
// std::cerr << "Document has "<< pcount << " page(s) " << endl;
if ( pcount > 0 ) // only here to avoid possible segfault, but PDF without page is not conform IIRC
{
- PoDoFo::PdfRect rect ( sourceDoc->GetPage ( 0 )->GetMediaBox() );
+ PoDoFo::PdfPage* pFirstPage = sourceDoc->GetPage ( 0 );
+ if ( NULL == pFirstPage ) // Fixes CVE-2019-9199 (issue #40)
+ {
+ PODOFO_RAISE_ERROR_INFO( ePdfError_PageNotFound, "First page (0) of source document not found" );
+ }
+ PoDoFo::PdfRect rect ( pFirstPage->GetMediaBox() );
// keep in mind its just a hint since PDF can have different page sizes in a same doc
sourceWidth = rect.GetWidth() - rect.GetLeft();
sourceHeight = rect.GetHeight() - rect.GetBottom() ;

@ -1,57 +0,0 @@
diff -rupN podofo-0.9.6/src/base/PdfString.cpp podofo-0.9.6-new/src/base/PdfString.cpp
--- podofo-0.9.6/src/base/PdfString.cpp 2018-03-10 17:30:53.000000000 +0100
+++ podofo-0.9.6-new/src/base/PdfString.cpp 2019-03-13 23:15:12.410138679 +0100
@@ -626,8 +626,19 @@ void PdfString::InitUtf8()
pdf_long lUtf8 = PdfString::ConvertUTF16toUTF8( reinterpret_cast<const pdf_utf16be*>(m_buffer.GetBuffer()),
this->GetUnicodeLength(),
reinterpret_cast<pdf_utf8*>(pBuffer), lBufferLen, ePdfStringConversion_Lenient );
+ if (lUtf8 + 1 > lBufferLen) // + 1 to account for 2 bytes termination here vs. 1 byte there
+ {
+ pBuffer = static_cast<char*>(podofo_realloc( pBuffer, lUtf8 + 1 ) );
+ if( !pBuffer )
+ {
+ PODOFO_RAISE_ERROR( ePdfError_OutOfMemory );
+ }
+ if (lUtf8 - 1 > lBufferLen)
+ lUtf8 = PdfString::ConvertUTF16toUTF8( reinterpret_cast<const pdf_utf16be*>(m_buffer.GetBuffer()),
+ this->GetUnicodeLength(), reinterpret_cast<pdf_utf8*>(pBuffer), lUtf8 + 1);
+ }
- pBuffer[lUtf8-1] = '\0';
+ pBuffer[lUtf8 - 1] = '\0';
pBuffer[lUtf8] = '\0';
m_sUtf8 = pBuffer;
podofo_free( pBuffer );
@@ -811,6 +822,7 @@ pdf_long PdfString::ConvertUTF16toUTF8(
return ConvertUTF16toUTF8( pszUtf16, lLen, pszUtf8, lLenUtf8 );
}
+// returns used, or if not enough memory passed in, needed length incl. 1 byte termination
pdf_long PdfString::ConvertUTF16toUTF8( const pdf_utf16be* pszUtf16, pdf_long lLenUtf16,
pdf_utf8* pszUtf8, pdf_long lLenUtf8,
EPdfStringConversion eConversion )
@@ -828,12 +840,21 @@ pdf_long PdfString::ConvertUTF16toUTF8(
size_t sLength = lLenUtf16;
size_t resultBufLength = lLenUtf8;
- u16_to_u8 ( s, sLength, pResultBuf, &resultBufLength);
+ uint8_t* pReturnBuf = u16_to_u8( s, sLength, pResultBuf, &resultBufLength );
+ if (pReturnBuf != pResultBuf)
+ {
+ free(pReturnBuf); // allocated by libunistring, so don't use podofo_free()
+ PdfError::LogMessage( eLogSeverity_Warning, "Output string size too little to hold it\n" );
+ return resultBufLength + 1;
+ }
pdf_long lBufferLen = PODOFO_MIN( static_cast<pdf_long>(resultBufLength + 1), lLenUtf8 );
- // Make sure buffer is 0 termnated
- pszUtf8[resultBufLength] = 0;
+ // Make sure buffer is 0 terminated
+ if ( static_cast<pdf_long>(resultBufLength + 1) <= lLenUtf8 )
+ pszUtf8[resultBufLength] = 0;
+ else
+ return resultBufLength + 1; // means: check for this in the caller to detect non-termination
return lBufferLen;
}

@ -1,6 +1,6 @@
diff -rupN --no-dereference podofo-0.9.6/src/base/PdfParser.h podofo-0.9.6-new/src/base/PdfParser.h diff -rupN --no-dereference podofo-0.9.7/src/podofo/base/PdfParser.h podofo-0.9.7-new/src/podofo/base/PdfParser.h
--- podofo-0.9.6/src/base/PdfParser.h 2018-04-30 21:21:55.000000000 +0200 --- podofo-0.9.7/src/podofo/base/PdfParser.h 2020-03-27 17:53:35.000000000 +0100
+++ podofo-0.9.6-new/src/base/PdfParser.h 2020-07-04 10:03:14.047752638 +0200 +++ podofo-0.9.7-new/src/podofo/base/PdfParser.h 2021-01-09 20:24:45.356918625 +0100
@@ -39,7 +39,7 @@ @@ -39,7 +39,7 @@
#include "PdfVecObjects.h" #include "PdfVecObjects.h"
@ -10,10 +10,10 @@ diff -rupN --no-dereference podofo-0.9.6/src/base/PdfParser.h podofo-0.9.6-new/s
namespace PoDoFo { namespace PoDoFo {
diff -rupN --no-dereference podofo-0.9.6/src/base/PdfXRefStreamParserObject.cpp podofo-0.9.6-new/src/base/PdfXRefStreamParserObject.cpp diff -rupN --no-dereference podofo-0.9.7/src/podofo/base/PdfXRefStreamParserObject.cpp podofo-0.9.7-new/src/podofo/base/PdfXRefStreamParserObject.cpp
--- podofo-0.9.6/src/base/PdfXRefStreamParserObject.cpp 2018-02-18 13:02:28.000000000 +0100 --- podofo-0.9.7/src/podofo/base/PdfXRefStreamParserObject.cpp 2020-10-10 19:17:47.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfXRefStreamParserObject.cpp 2020-07-04 10:03:14.047752638 +0200 +++ podofo-0.9.7-new/src/podofo/base/PdfXRefStreamParserObject.cpp 2021-01-09 20:24:45.356918625 +0100
@@ -223,7 +223,7 @@ void PdfXRefStreamParserObject::ReadXRef @@ -237,7 +237,7 @@ void PdfXRefStreamParserObject::ReadXRef
{ {
int i; int i;
pdf_int64 z; pdf_int64 z;
@ -22,7 +22,7 @@ diff -rupN --no-dereference podofo-0.9.6/src/base/PdfXRefStreamParserObject.cpp
for( i=0;i<W_ARRAY_SIZE;i++ ) for( i=0;i<W_ARRAY_SIZE;i++ )
{ {
@@ -239,7 +239,8 @@ void PdfXRefStreamParserObject::ReadXRef @@ -253,7 +253,8 @@ void PdfXRefStreamParserObject::ReadXRef
nData[i] = 0; nData[i] = 0;
for( z=W_MAX_BYTES-lW[i];z<W_MAX_BYTES;z++ ) for( z=W_MAX_BYTES-lW[i];z<W_MAX_BYTES;z++ )
{ {
@ -32,9 +32,9 @@ diff -rupN --no-dereference podofo-0.9.6/src/base/PdfXRefStreamParserObject.cpp
++pBuffer; ++pBuffer;
} }
} }
diff -rupN --no-dereference podofo-0.9.6/src/base/PdfXRefStreamParserObject.h podofo-0.9.6-new/src/base/PdfXRefStreamParserObject.h diff -rupN --no-dereference podofo-0.9.7/src/podofo/base/PdfXRefStreamParserObject.h podofo-0.9.7-new/src/podofo/base/PdfXRefStreamParserObject.h
--- podofo-0.9.6/src/base/PdfXRefStreamParserObject.h 2014-06-07 00:13:22.000000000 +0200 --- podofo-0.9.7/src/podofo/base/PdfXRefStreamParserObject.h 2019-05-23 12:08:59.000000000 +0200
+++ podofo-0.9.6-new/src/base/PdfXRefStreamParserObject.h 2020-07-04 10:03:14.047752638 +0200 +++ podofo-0.9.7-new/src/podofo/base/PdfXRefStreamParserObject.h 2021-01-09 20:24:45.356918625 +0100
@@ -38,7 +38,7 @@ @@ -38,7 +38,7 @@
#include "PdfParserObject.h" #include "PdfParserObject.h"

@ -1,31 +0,0 @@
Description: Fix pkg-config to actually work with the way podofo is installed
Author: Mattia Rizzolo <mattia@debian.org>
Bug: https://sourceforge.net/p/podofo/tickets/30
Bug-Debian: https://bugs.debian.org/908134
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libpodofo/+bug/1792407
Last-Update: 2018-09-18
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -314,10 +314,10 @@
MESSAGE("Pkg-config found, creating a pkg-config file for linking against shared library.")
CONFIGURE_FILE(
"libpodofo.pc.in"
- "${PoDoFo_BINARY_DIR}/libpodofo-${PODOFO_VERSION_MAJOR}.pc"
+ "${PoDoFo_BINARY_DIR}/libpodofo.pc"
@ONLY)
INSTALL(
- FILES "${PoDoFo_BINARY_DIR}/libpodofo-${PODOFO_VERSION_MAJOR}.pc"
+ FILES "${PoDoFo_BINARY_DIR}/libpodofo.pc"
DESTINATION "${LIBDIRNAME}/pkgconfig")
ELSE(PKG_CONFIG_FOUND)
MESSAGE("Pkg-config not found. No pkg-config file will be created.")
--- a/src/libpodofo.pc.in
+++ b/src/libpodofo.pc.in
@@ -6,5 +6,5 @@
Name: @CMAKE_PROJECT_NAME@
Description: A C++ library to work with the PDF file format
Version: @PODOFO_VERSION@
-Libs: -L${libdir} -lpodofo-@PODOFO_VERSION_MAJOR@
+Libs: -L${libdir} -lpodofo
Cflags: -I${includedir}

@ -1,14 +0,0 @@
diff -rupN podofo-0.9.6/test/TokenizerTest/CMakeLists.txt podofo-0.9.6-new/test/TokenizerTest/CMakeLists.txt
--- podofo-0.9.6/test/TokenizerTest/CMakeLists.txt 2007-09-16 11:33:38.000000000 +0200
+++ podofo-0.9.6-new/test/TokenizerTest/CMakeLists.txt 2019-03-13 23:15:12.116138755 +0100
@@ -2,10 +2,3 @@ ADD_EXECUTABLE(TokenizerTest TokenizerTe
TARGET_LINK_LIBRARIES(TokenizerTest ${PODOFO_LIB} ${PODOFO_LIB_DEPENDS})
SET_TARGET_PROPERTIES(TokenizerTest PROPERTIES COMPILE_FLAGS "${PODOFO_CFLAGS}")
ADD_DEPENDENCIES(TokenizerTest ${PODOFO_DEPEND_TARGET})
-
-# Copy the test samples over to the build tree
-ADD_CUSTOM_COMMAND(
- TARGET TokenizerTest
- POST_BUILD
- COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/objects" "${CMAKE_CURRENT_BINARY_DIR}/objects"
- )

@ -1 +1 @@
SHA512 (podofo-0.9.6.tar.gz) = 35c1a457758768bdadc93632385f6b9214824fead279f1b85420443fb2135837cefca9ced476df0d47066f060e9150e12fcd40f60fa1606b177da433feb20130 SHA512 (podofo-0.9.7.tar.gz) = 0e699739c2fb7d4d02ffca371504bb19f3a8a97ddcbfc06f8d9636db9e73064b4f633f7f09bce92140bb2174610ad68c1e5f8460d474d176ab803ed28295251b

Loading…
Cancel
Save