You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ti...@apache.org on 2018/09/03 15:54:03 UTC
svn commit: r1839972 -
/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Author: tilman
Date: Mon Sep 3 15:54:03 2018
New Revision: 1839972
URL: http://svn.apache.org/viewvc?rev=1839972&view=rev
Log:
PDFBOX-4308: prevent object that is referenced several times from being written direct and indirect, thus getting encrypted with wrong object number or getting encrypted twice
Modified:
pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1839972&r1=1839971&r2=1839972&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Mon Sep 3 15:54:03 2018
@@ -927,8 +927,12 @@ public class COSWriter implements ICOSVi
else if( current instanceof COSObject )
{
COSBase subValue = ((COSObject)current).getObject();
- if (incrementalUpdate || subValue instanceof COSDictionary || subValue == null)
+ if (willEncrypt || incrementalUpdate || subValue instanceof COSDictionary || subValue == null)
{
+ // PDFBOX-4308: added willEncrypt to prevent an object
+ // that is referenced several times from being written
+ // direct and indirect, thus getting encrypted
+ // with wrong object number or getting encrypted twice
addObjectToWrite( current );
writeReference( current );
}
@@ -1025,8 +1029,12 @@ public class COSWriter implements ICOSVi
else if( value instanceof COSObject )
{
COSBase subValue = ((COSObject)value).getObject();
- if (incrementalUpdate || subValue instanceof COSDictionary || subValue == null)
+ if (willEncrypt || incrementalUpdate || subValue instanceof COSDictionary || subValue == null)
{
+ // PDFBOX-4308: added willEncrypt to prevent an object
+ // that is referenced several times from being written
+ // direct and indirect, thus getting encrypted
+ // with wrong object number or getting encrypted twice
addObjectToWrite( value );
writeReference( value );
}