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

John Hewson edited comment on PDFBOX-1981 at 3/12/14 9:25 PM:
--------------------------------------------------------------

Confirmed. The cause of this regression that I replaced the following function:

{code}
private static final boolean arraysEqual( byte[] first, byte[] second, int 
count )
{
    // both arrays have to have a minimum length of count
    if (first.length < count || second.length < count)
    {
        return false;
    }
    for( int i=0; i<count; i++ )
    {
        if( first[i] != second[i])
        {
            return false;
        }
    }
    return true;
}
{code}

with Arrays.equals and a length check. However, arraysEqual doesn't check if 
the arrays are equal! It's actually checking if the first _n_ elements are 
equal. I've fixed this and made it less confusing in revision 1576920. Thanks 
for the test case.


was (Author: jahewson):
Confirmed. The cause of this regression was the I removed the following 
function:

{code}
private static final boolean arraysEqual( byte[] first, byte[] second, int 
count )
{
    // both arrays have to have a minimum length of count
    if (first.length < count || second.length < count)
    {
        return false;
    }
    for( int i=0; i<count; i++ )
    {
        if( first[i] != second[i])
        {
            return false;
        }
    }
    return true;
}
{code}

with Arrays.equals and a length check. However, arraysEqual doesn't check if 
the arrays are equal! It's actually checking if the first _n_ elements are 
equal. I've fixed this and made it less confusing in revision 1576920. Thanks 
for the test case.

> CryptographyException for file that isn't encrypted
> ---------------------------------------------------
>
>                 Key: PDFBOX-1981
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1981
>             Project: PDFBox
>          Issue Type: Bug
>    Affects Versions: 2.0.0
>            Reporter: Tilman Hausherr
>            Assignee: John Hewson
>              Labels: regression
>             Fix For: 2.0.0
>
>         Attachments: Rennie-Fresh-gebrauchsinformation.pdf
>
>
> I get this with the attached file:
> Exception in file: rennie-fresh-gebrauchsinformation.pdf
> java.io.IOException: Error (CryptographyException) while creating security 
> handler for decryption: The supplied password does not match either the owner 
> or user password in the document
> 12.03.2014 20:44:06.063 ERROR [main] 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser:1888 - Can't find the 
> object xref at offset 4543
>       at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.initialParse(NonSequentialPDFParser.java:444)
>       at 
> org.apache.pdfbox.pdfparser.NonSequentialPDFParser.parse(NonSequentialPDFParser.java:741)
>       at org.apache.pdfbox.pdmodel.PDDocument.loadNonSeq(PDDocument.java:1152)
>       at org.apache.pdfbox.pdmodel.PDDocument.loadNonSeq(PDDocument.java:1135)
>       at pdfboxpageimageextraction.ExtractImages.doPdf(ExtractImages.java:203)
>       at pdfboxpageimageextraction.ExtractImages.main(ExtractImages.java:86)
> This didn't happen ~ 2 weeks ago, so I suspect its a regression.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to