Package: python-poppler
Version: 0.12.1-8+b1
Severity: important
Tags: upstream patch
Dear Maintainer,
The following code:
$ cat bug.py
import poppler
import tempfile
import urllib2
# Download a PDF.
dummy, filename = tempfile.mkstemp(".pdf")
pdf = urllib2.urlopen("http://www.aquilenet.fr/docs/adhesion.pdf")
local_pdf = open(filename, 'w')
local_pdf.write(pdf.read())
local_pdf.close()
pdf.close()
# Get the thumbnail.
page = poppler.document_new_from_file('file://' + filename, None).get_page(0)
page.get_thumbnail()
leads to a segmentation fault when the PDF file does not have a thumbnail for
the page:
$ python bug.py
Segmentation fault
Basically, the _wrap_poppler_page_get_thumbnail() function calls the
poppler_page_get_thumbnail() function, but does not check that the return value
is not NULL before passing it to PycairoSurface_FromSurface(), which
dereferences it.
The attached patch fixes this issue. The get_thumbnail() method now returns None
when no thumbnail is available. I'm not familiar with the python-poppler, so
this may not be the best solution (maybe an exception should be thrown instead).
This error can be found in other methods, such as get_image(), so this is
probably worth notifying upstream.
WBR,
Cyril Roelandt.
-- System Information:
Debian Release: wheezy/sid
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.2.0-3-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-poppler depends on:
ii libatk1.0-0 2.4.0-2
ii libc6 2.13-35
ii libcairo2 1.12.2-2
ii libfontconfig1 2.9.0-7
ii libfreetype6 2.4.9-1
ii libgdk-pixbuf2.0-0 2.26.1-1
ii libglib2.0-0 2.32.3-1
ii libgtk2.0-0 2.24.10-2
ii libpango1.0-0 1.30.0-1
ii libpoppler-glib8 0.18.4-3
ii python 2.7.3-2
ii python-cairo 1.8.8-1+b2
ii python-gobject 3.2.2-1
ii python-gtk2 2.24.0-3
ii python2.6 2.6.8-0.2
ii python2.7 2.7.3-5
python-poppler recommends no packages.
python-poppler suggests no packages.
-- no debconf information
--- python-poppler-0.12.1.orig/poppler.override 2009-09-26 20:31:23.000000000 +0200
+++ python-poppler-0.12.1/poppler.override 2012-09-22 00:09:57.000000000 +0200
@@ -569,6 +569,9 @@
surface = poppler_page_get_thumbnail(POPPLER_PAGE(self->obj));
+ if (!surface)
+ return Py_BuildValue("");
+
#if PYCAIRO_VERSION_HEX >= 0x1010600
return PycairoSurface_FromSurface(surface, NULL);
#else