parent
81d1a4835b
commit
a1a7386ad9
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,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,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…
Reference in new issue