[ 
https://issues.apache.org/jira/browse/PDFBOX-4554?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16851841#comment-16851841
 ] 

Tilman Hausherr commented on PDFBOX-4554:
-----------------------------------------

How would it prevent it? If you want to load the PDF *file* into a byte array 
for speed, then you'll need to create it once.

And byte arrays are also created when calling {{getSignedContent()}}, both 
without and with your patch. And you can pass the same byte array for each 
signature. There is no need to pass a different array.

You still seem to think that you need to create a different byte array for each 
revision. No you don't. Pass the same one.

I see I forgot to answer one:
{quote}
but what about when it is not 0 and buf.length?
{quote}
That doesn't matter, because {{COSFilterInputStream}} is always called with the 
{{byteRange}} as parameter. I think it would break if you cut off the PDF at 
that place, because the byte range is always applied to the *full* file. 
{{COSFilterInputStream}} didn't have a javadoc until recently. What it does is 
that includes the bytes that are in the (begin , length) intervals passed in 
the constructor.

In my unit tests there is a file that is signed twice. The byte ranges are
{noformat}
/ByteRange [0 390221 409231 27998]
/ByteRange [0 439292 458302 27982]
{noformat}
So this means that the part that is signed for the first ones are the bytes 
from pos 0 to 390221-1 and from 409231 to 409231+27998-1, and for the second 
signature the bytes from pos 0 to 439292 and from 458302 to 458302+27982-1.

> operations taking a byte[] need to allow for offset and length too
> ------------------------------------------------------------------
>
>                 Key: PDFBOX-4554
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-4554
>             Project: PDFBox
>          Issue Type: Improvement
>            Reporter: Jason Pyeron
>            Priority: Major
>
> Without this, massive amounts of memory must be copied/allocated to "trim" 
> byte[].
> See forthcoming pull request.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to