Bug 692882 - mupdf crashed while LATEX generated PDF opened
Summary: mupdf crashed while LATEX generated PDF opened
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: PC Linux
: P4 major
Assignee: Tor Andersson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-27 17:51 UTC by Pavel Zhukov
Modified: 2012-03-13 19:41 UTC (History)
2 users (show)

See Also:
Customer:
Word Size: ---


Attachments
a pdf with a stupidously long pdfdoc title (27.29 KB, application/pdf)
2012-03-11 02:51 UTC, Hin-Tak Leung
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pavel Zhukov 2012-02-27 17:51:34 UTC
Crash report can be found here: https://bugzilla.redhat.com/show_bug.cgi?id=752388
I've reproduced bug for all latex generated PDFs.
Comment 1 Robin Watts 2012-03-08 18:35:41 UTC
Can you attach the file that crashes please? I can't see it on the redhat bug report.
Comment 2 Hin-Tak Leung 2012-03-11 02:38:32 UTC
(In reply to comment #0)
> Crash report can be found here:
> https://bugzilla.redhat.com/show_bug.cgi?id=752388
> I've reproduced bug for all latex generated PDFs.

Really? I have mupdf-0.9-1.fc16.x86_64 and tried a few latex-generated PDFs.

From the two redhat bugzilla backtraces though, it looks like it is string
buffer overrun. Does your LaTeX pdf's have extremely long titles?

apps/pdfapps.c: line 360 -ish, have this:

-----------
static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int
repaint)
{
        char buf[256];
-----------

could you try changing the 256 to some large number, and/or the sprintf() a few
lines down, to snprintf(buf, 256, ...)?

---------------
        if (drawpage)
        {
            sprintf(buf, "%s - %d/%d (%d dpi)", app->doctitle,
-------------
Comment 3 Hin-Tak Leung 2012-03-11 02:51:17 UTC
Created attachment 8411 [details]
a pdf with a stupidously long pdfdoc title

Based on my inspection of the mupdf code and my suspection that I can overrun that string buffer, I made a pdf with a stupideously long pdfdoc title. And it crashes mupdf. Both xpdf and gs are happy to open it.
Comment 4 Robin Watts 2012-03-13 19:41:24 UTC
Fixed in:

commit 33dc06b61c0816854193f006c35a9e797f098a22
Author: Robin Watts <robin.watts@artifex.com>
Date:   Tue Mar 13 19:38:56 2012 +0000

    Bug 692882 - fix buffer overflow.

    Long doctitles (filenames in this case) can cause a buffer overflow.
    Fix here. Thanks to Hin-Tak and Pavel Zhukov.

Thanks!