rarmknecht / peepdf

Automatically exported from code.google.com/p/peepdf
GNU General Public License v3.0
0 stars 0 forks source link

metadata command crashed peepdf #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. running metadata in the console on a malformed PDF

What is the expected output? What do you see instead?
The program crashed with:

Traceback (most recent call last):
  File "/home/.../bin/peepdf.py", line 465, in <module>
    console.cmdloop(stats + newLine)
  File "/usr/lib64/python2.6/cmd.py", line 142, in cmdloop
    stop = self.onecmd(line)
  File "/usr/lib64/python2.6/cmd.py", line 219, in onecmd
    return func(arg)
  File "/home/.../src/svn/sec/peepdf-read-only/PDFConsole.py", line 2290, in do_metadata
    type = object.getElementByName('/Type').getValue()
AttributeError: 'list' object has no attribute 'getValue'

What version of the product are you using? On what operating system?
r158 from svn

Please provide any additional information below.

I don't know if the patch is the right long-term solution, but it solved my 
crash.

Maybe every interactive command should be in a try/except block, so the program 
does not crash on the user?

Original issue reported on code.google.com by bta...@gmail.com on 30 Nov 2012 at 3:27

Attachments:

GoogleCodeExporter commented 9 years ago
Hi! Could you also attach the PDF file to test it, please?

Thanks! 

Original comment by josemigu...@gmail.com on 30 Nov 2012 at 3:38

GoogleCodeExporter commented 9 years ago
Is that ok to attach it here even if it's a malicious PDF?

Original comment by bta...@gmail.com on 30 Nov 2012 at 3:42

GoogleCodeExporter commented 9 years ago
The attached file was extracted from the original malicious file; you should be 
able to load it and crash peepdf when running the metadata command on it.

Original comment by bta...@gmail.com on 30 Nov 2012 at 4:41

Attachments:

GoogleCodeExporter commented 9 years ago
Here's a patch that adds generic exception handling to Peepdf's interactive 
console.

The program will still show the traceback from the exception, so one can have a 
clue what the problem was about.

It also solves my previous metadata problem.

Original comment by bta...@gmail.com on 4 Dec 2012 at 11:51

Attachments:

GoogleCodeExporter commented 9 years ago
Hi! I have added the fix for the metadata command and also I have added a 
better exception handling as you suggested ;) Thanks for the feedback and code!

Original comment by josemigu...@gmail.com on 23 Apr 2013 at 12:25