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:09 UTC
svn commit: r1839973 -
/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Author: tilman
Date: Mon Sep 3 15:54:09 2018
New Revision: 1839973
URL: http://svn.apache.org/viewvc?rev=1839973&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/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
Modified: pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java?rev=1839973&r1=1839972&r2=1839973&view=diff
==============================================================================
--- pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java (original)
+++ pdfbox/branches/2.0/pdfbox/src/main/java/org/apache/pdfbox/pdfwriter/COSWriter.java Mon Sep 3 15:54:09 2018
@@ -928,8 +928,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 );
}
@@ -1026,8 +1030,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 );
}