Opened 8 years ago

Closed 8 years ago

#288 closed defect (fixed)

Crash when loading a corrupt PDF

Reported by: dryeo Owned by: Gregg Young
Priority: major Milestone: 1.4.0
Component: Backend Version: 1.3.6
Keywords: Cc: dave.r.yeo@…

Description

When loading the attached corrupt PDF, Lucide crashes, see attached trp file. Other PDF readers error out with a message about not being able to display the PDF or similar, or in the case of the JS viewer, just don't show anything. The exception being qpdfview which also crashes. Note that this is actually 1.36rc1

Attachments (2)

31VB5600.pdf (141.2 KB ) - added by dryeo 8 years ago.
Corrupt PDF
00E6_03.TRP (21.8 KB ) - added by dryeo 8 years ago.
trp file

Download all attachments as: .zip

Change History (13)

by dryeo, 8 years ago

Attachment: 31VB5600.pdf added

Corrupt PDF

by dryeo, 8 years ago

Attachment: 00E6_03.TRP added

trp file

comment:1 by dryeo, 8 years ago

Note that the PDF was probably an incomplete download of a owners manual for a lawnmower. Similar PDFs are about 1.5 MBs

comment:2 by Gregg Young, 8 years ago

This is occurring while a thumbnail is being created. ea_data is probably garbage. Need a way to check if the file is really a valid pdf before making the thumbnail.

comment:3 by Gregg Young, 8 years ago

See code in LoadFile (lupoppler.cpp ~1568) Use this check in makeThumbs? Then report error.

newDoc = new PDFDoc(filename_g, password_g, password_g);

if (password_g) {

delete password_g;

}

if (!newDoc->isOk()) {

err = newDoc->getErrorCode(); delete newDoc;

if ( errorCode != NULL ) {

switch ( err ) {

case errOpenFile:

*errorCode = LU_LDERR_OPEN_ERROR; break;

case errBadCatalog: case errDamaged:

*errorCode = LU_LDERR_DAMAGED; break;

case errEncrypted:

*errorCode = LU_LDERR_ENCRYPTED; break;

case errFileIO:

*errorCode = LU_LDERR_READ_ERROR; break;

default:

*errorCode = LU_LDERR_CUSTOM; set_error( error, "(error %d)", err ); break;

}

}

return FALSE;

comment:4 by Gregg Young, 8 years ago

Owner: set to Gregg Young
Status: newassigned

OK you can actually open this file in Lucide. If you turn off the thumbnail code it opens with a table of contents in the navigation window but no page in the main window. After discovering this I checked to see if getPageCount was greater than 0 and returned if it wasn't (as in this case). This fixed the problem with this file.

comment:5 by Gregg Young, 8 years ago

Resolution: fixed
Status: assignedclosed

CS [536]

comment:6 by Gregg Young, 8 years ago

Resolution: fixed
Status: closedreopened

comment:7 by Gregg Young, 8 years ago

I reopened this to discuss how to handle this error. I added code which prevents this file from loading and gives an error message "Load error: The PDF has no pages!". Of course this does prevent someone from viewing the table of contents which is present in this case. Is this an acceptable solution?

comment:8 by Gregg Young, 8 years ago

I could use the less descriptive but already present and translated "Load error: File damaged!". This would save having to translate the message and probably would be just as good for most end users.

comment:9 by Gregg Young, 8 years ago

Milestone: 1.4.0

comment:10 by dryeo, 8 years ago

I think the "Load error: file damaged" message might be better as it informs the user of a damaged file rather then an improperly created PDF.

comment:11 by Gregg Young, 8 years ago

Resolution: fixed
Status: reopenedclosed

Went with Dave's suggestion above CS [541]

Note: See TracTickets for help on using tickets.