[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

rpms/kdegraphics/devel kdegraphics-3.4.2-kpdf-110000.patch, NONE, 1.1 kdegraphics-3.4.2-kpdf-crash.patch, NONE, 1.1 kdegraphics.spec, 1.55, 1.56



Author: than

Update of /cvs/dist/rpms/kdegraphics/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv23319

Modified Files:
	kdegraphics.spec 
Added Files:
	kdegraphics-3.4.2-kpdf-110000.patch 
	kdegraphics-3.4.2-kpdf-crash.patch 
Log Message:
backport CVS patch to fix crash in kpdf


kdegraphics-3.4.2-kpdf-110000.patch:
 PDFDoc.cc |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

--- NEW FILE kdegraphics-3.4.2-kpdf-110000.patch ---
--- kdegraphics-3.4.2/kpdf/xpdf/xpdf/PDFDoc.cc.tn	2005-08-31 13:06:28.000000000 +0200
+++ kdegraphics-3.4.2/kpdf/xpdf/xpdf/PDFDoc.cc	2005-08-31 13:06:41.000000000 +0200
@@ -115,23 +115,34 @@
 GBool PDFDoc::setup(GString *ownerPassword, GString *userPassword) {
   str->reset();
   
-  char eof[8];
+  char *eof = new char[1025];
   int pos = str->getPos();
-  str->setPos(7, -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] = '\0';
-  if (strstr(eof, "%%EOF") == NULL)
+  str->setPos(1024, -1);
+  int i, ch;
+  for (i = 0; i < 1024; i++)
+  {
+    ch = str->getChar();
+    if (ch == EOF)
+      break;
+    eof[i] = ch;
+  }
+  eof[i] = '\0';
+  
+  bool found = false;
+  for (i = i - 5; i >= 0; i--) {
+    if (strncmp (&eof[i], "%%EOF", 5) == 0) {
+      found = true;
+      break;
+    }
+  }
+  if (!found)
   {
     error(-1, "Document does not have ending %%EOF");	      
     errCode = errDamaged;
+    delete[] eof;
     return gFalse;
   }
+  delete[] eof;
   
   str->setPos(pos);
   

kdegraphics-3.4.2-kpdf-crash.patch:
 DCTStream.cc |   45 ++++++++++++++++++++++++++++++++++++++++++++-
 DCTStream.h  |    1 +
 2 files changed, 45 insertions(+), 1 deletion(-)

--- NEW FILE kdegraphics-3.4.2-kpdf-crash.patch ---
--- kdegraphics-3.4.2/kpdf/xpdf/xpdf/DCTStream.h.tn	2005-08-31 13:14:50.000000000 +0200
+++ kdegraphics-3.4.2/kpdf/xpdf/xpdf/DCTStream.h	2005-08-31 13:15:01.000000000 +0200
@@ -44,6 +44,7 @@
     struct jpeg_source_mgr pub;
     JOCTET buffer;
     Stream *str;
+    int index;
 };
 
 
--- kdegraphics-3.4.2/kpdf/xpdf/xpdf/DCTStream.cc.tn	2005-08-31 13:14:45.000000000 +0200
+++ kdegraphics-3.4.2/kpdf/xpdf/xpdf/DCTStream.cc	2005-08-31 13:15:04.000000000 +0200
@@ -15,7 +15,15 @@
 static boolean str_fill_input_buffer(j_decompress_ptr cinfo)
 {
   struct str_src_mgr * src = (struct str_src_mgr *)cinfo->src;
-  src->buffer = src->str->getChar();
+  if (src->index == 0) {
+    src->buffer = 0xFF;
+    src->index++;
+  }
+  else if (src->index == 1) {
+    src->buffer = 0xD8;
+    src->index++;
+  }
+  else src->buffer = src->str->getChar();
   src->pub.next_input_byte = &src->buffer;
   src->pub.bytes_in_buffer = 1;
   return TRUE;
@@ -50,6 +58,7 @@
   src.pub.bytes_in_buffer = 0;
   src.pub.next_input_byte = NULL;
   src.str = str;
+  src.index = 0;
   cinfo.src = (jpeg_source_mgr *)&src;
   cinfo.err = jpeg_std_error(&jerr);
   x = 0;
@@ -64,6 +73,40 @@
   int row_stride;
 
   str->reset();
+  
+  // JPEG data has to start with 0xFF 0xD8
+  // but some pdf like the one on 
+  // https://bugs.freedesktop.org/show_bug.cgi?id=3299
+  // does have some garbage before that this seeks for
+  // the start marker...
+  bool startFound = false;
+  int c = 0, c2 = 0;
+  int n = 0;
+  while (!startFound)
+  {
+    if (!c)
+    {
+      c = str->getChar();
+      if (c != 0xFF) c = 0;
+      if (c == -1)
+      {
+        error(-1, "Could not find start of jpeg data");
+        exit(1);
+      }
+    }
+    else
+    {
+      c2 = str->getChar();
+      if (c2 != 0xD8)
+      {
+        c = 0;
+        c2 = 0;
+      }
+      else startFound = true;
+    }
+    n++;
+  }
+
   jpeg_read_header(&cinfo, TRUE);
   jpeg_start_decompress(&cinfo);
 


Index: kdegraphics.spec
===================================================================
RCS file: /cvs/dist/rpms/kdegraphics/devel/kdegraphics.spec,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- kdegraphics.spec	31 Aug 2005 10:53:43 -0000	1.55
+++ kdegraphics.spec	31 Aug 2005 11:21:31 -0000	1.56
@@ -29,6 +29,8 @@
 # upstream patches
 Patch100: kdegraphics-3.4.2-kpdf-110199.patch
 Patch101: kdegraphics-3.4.2-kpdf-110171.patch
+Patch102: kdegraphics-3.4.2-kpdf-110000.patch
+Patch103: kdegraphics-3.4.2-kpdf-crash.patch
 
 %ifnarch %{no_scanner_archs}
 BuildRequires: sane-backends-devel >= 1.0.3-10
@@ -265,6 +267,8 @@
 %patch2 -p1 -b .xorg
 %patch100 -p1 -b .kpdf-110199
 %patch101 -p1 -b .kpdf-110171
+%patch102 -p1 -b .kddf-110000
+%patch103 -p1 -b .crash
 
 %if %{rhel}
   echo "DO_NOT_COMPILE=\"\$DO_NOT_COMPILE kfax\"" >kfax/configure.in.in
@@ -364,7 +368,9 @@
 %changelog
 * Wed Aug 31 2005 Than Ngo <than redhat com> 7:3.4.2-2
 - backport CVS patch to fix rendering problem in kpdf
-- Backport CVS patch to fix bug #kde110171
+- backport CVS patch to fix bug #kde110171
+- backport CVS patch to fix bug #kde110034, #kde110000
+- backport CVS patch to fix crash in kpdf
 
 * Thu Aug 11 2005 Than Ngo <than redhat com> 7:3.4.2-1
 - update to 3.4.2


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]