Bug 110000

Summary: Regression from kpdf 3.4.1 (kpdf 0.4.2 cannot open PDF file anymore that used to work with 0.4.1)
Product: [Applications] kpdf Reporter: Michael Nottebrock <lofi>
Component: generalAssignee: Albert Astals Cid <aacid>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: FreeBSD Ports   
OS: FreeBSD   
Latest Commit: Version Fixed In:

Description Michael Nottebrock 2005-08-02 02:58:56 UTC
Version:            (using KDE KDE 3.4.2)
Installed from:    FreeBSD Ports
OS:                FreeBSD

It seems there are regressions in kpdf 3.4.2's code that prevent it from reading some PDFs of mine which all worked for me in kpdf 3.4.1 (and still do when I install kdegraphics 3.4.1 into my KDE 3.4.2 environment).

However: Those documents are my telephone and online bills, and I don't want to attach them to this bugreport for anyone to read. I can make them available to interested developers on request however - please reply to this bugreport or contact me directly.
Comment 1 Michael Nottebrock 2005-08-02 03:40:37 UTC
N.B.: Latest kpdf from branches/3.4 doesn't work either.
Comment 2 Albert Astals Cid 2005-08-02 16:01:22 UTC
You mean that kpdf 0.4.1 + KDE 3.4.1 works but kpdf 0.4.1 + KDE 3.4.2 does not work?
Comment 3 Michael Nottebrock 2005-08-02 16:39:13 UTC
No, kpdf 0.4.2 + KDE 3.4.2 does not work, but kpdf 0.4.1 and KDE 3.4.2 does.
Comment 4 Albert Astals Cid 2005-08-02 18:12:44 UTC
Ok, i misunderstood you then. 3.4.2 has a few changes that can be responsible for that, if you can send me that pdf i can try to see why it is happening, i promise to delete the documents after fixing.
Comment 5 Albert Astals Cid 2005-08-02 19:08:20 UTC
SVN commit 442429 by aacid:

Increase even more the bytes where we search for %%EOF up to the 1024 bytes the pdf spec says adobe checks for
Michael that fixes the doc you sent me, does the same with all that failed for you?
BUGS: 110000


 M  +6 -11     PDFDoc.cc  


--- branches/KDE/3.5/kdegraphics/kpdf/xpdf/xpdf/PDFDoc.cc #442428:442429
@@ -115,24 +115,19 @@
 GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) {
   str->reset();
   
-  char eof[9];
+  char *eof = new char[1024];
   int pos = str->getPos();
-  str->setPos(8, -1);
-  eof[0] = str->getChar();
-  eof[1] = str->getChar();
-  eof[2] = str->getChar();
-  eof[3] = str->getChar();
-  eof[4] = str->getChar();
-  eof[5] = str->getChar();
-  eof[6] = str->getChar();
-  eof[7] = str->getChar();
-  eof[8] = '\0';
+  str->setPos(1024, -1);
+  for (int i = 0; i < 1024; i++) eof[i] = str->getChar();
+  eof[1024] = '\0';
   if (strstr(eof, "%%EOF") == NULL)
   {
     error(-1, "Document does not have ending %%EOF");
     errCode = errDamaged;
+    delete[] eof;
     return gFalse;
   }
+  delete[] eof;
   
   str->setPos(pos);
   
Comment 6 Michael Nottebrock 2005-08-02 20:38:22 UTC
Indeed it does. Thank you very much!