Bug#896596: poppler-glib always returns 0 length for PopplerInputStream

Simon McVittie smcv at debian.org
Thu Feb 14 10:12:03 GMT 2019


Control: tags -1 + patch

On Sat, 28 Apr 2018 at 20:59:16 +0900, dai at debian.org wrote:
> original bug report: https://bugs.debian.org/896596
> previous forwarded: https://github.com/ruby-gnome2/ruby-gnome2/issues/1159
> 
> below comments and patch by Kouhei Sutou <kou at cozmixng.org>.
> 
> > Poppler adds getLength() check at
> > https://cgit.freedesktop.org/poppler/poppler/commit/?id=a59f61641fcb36859b625749afb4561557e419f6
> > for https://bugs.freedesktop.org/show_bug.cgi?id=103552 .
> > But PopplerInputStream created by poppler-glib always returns 0 for getLength():
> > https://cgit.freedesktop.org/poppler/poppler/tree/glib/poppler-document.cc#n301

Thanks for this diagnosis. It seems correct.

> > Ah, we can just use the length passed by argument:
> -    str = new PopplerInputStream(stream, cancellable, 0, gFalse, 0, Object(objNull));
> +    str = new PopplerInputStream(stream, cancellable, 0, gFalse, length, Object(objNull));

That doesn't actually work, because the function is documented to accept
-1 as a length (meaning "find the length automatically").

> > We'll be able to compute length by g_seekable_seek(0, G_SEEK_END) and
> > g_seekable_tell().

That's what I've done in the case where the caller used -1. The function
already requires that the stream is seekable, so it seems safe to assume
that this works.

Proposed patches attached. I've included a fairly minimal reproducer for
the bug, as a patch to the existing autopkgtest.

Also available as a merge request, here:
https://salsa.debian.org/freedesktop-team/poppler/merge_requests/1

Patch proposed upstream here:
https://gitlab.freedesktop.org/poppler/poppler/merge_requests/189

    smcv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-patch-to-fix-poppler_document_new_from_stream-re.patch
Type: text/x-diff
Size: 2711 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-freedesktop-maintainers/attachments/20190214/aabf4bf5/attachment.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-d-tests-glib-Add-a-test-for-896596.patch
Type: text/x-diff
Size: 2765 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-freedesktop-maintainers/attachments/20190214/aabf4bf5/attachment-0001.patch>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0003-Update-changelog.patch
Type: text/x-diff
Size: 742 bytes
Desc: not available
URL: <http://alioth-lists.debian.net/pipermail/pkg-freedesktop-maintainers/attachments/20190214/aabf4bf5/attachment-0002.patch>


More information about the Pkg-freedesktop-maintainers mailing list