Bug 103910 - Segfault on pdfsig when printing Signer full Distinguished Name
Summary: Segfault on pdfsig when printing Signer full Distinguished Name
Status: RESOLVED FIXED
Alias: None
Product: poppler
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: poppler-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-11-26 09:12 UTC by Theofilos Intzoglou
Modified: 2018-07-22 22:19 UTC (History)
3 users (show)

See Also:
i915 platform:
i915 features:


Attachments
SignatureHandler-calloc.patch (666 bytes, patch)
2017-11-26 09:12 UTC, Theofilos Intzoglou
Details | Splinter Review
subjectdn_mem_alloc.patch (2.63 KB, patch)
2017-12-07 20:18 UTC, Theofilos Intzoglou
Details | Splinter Review

Description Theofilos Intzoglou 2017-11-26 09:12:24 UTC
Created attachment 135716 [details] [review]
SignatureHandler-calloc.patch

Inside SignatureHandler.cc and specifically in SignatureHandler::getSignerSubjectDN() the subjectName of cert is read and returned back to validateSignature() of Form.cc and then to pdfsig.cc. Returning to pdfsig.cc though signature_handler is destroyed and as a result the pointer to subjectName is invalid. I am attaching a small patch that allocates memory for subjectName before returning to avoid segfault but this memory should be freed after usage. The patch attached is an example, not as a patch to be merged to master :-)
Comment 1 Theofilos Intzoglou 2017-11-26 11:33:31 UTC
Forgot to post url of pdf that causes the segfault: https://blogs.adobe.com/security/SampleSignedPDFDocument.pdf
Comment 2 Albert Astals Cid 2017-12-02 10:05:53 UTC
There's lots of wrong stuff in signature handling memory it seems.

This is the valgrind trace i get when running pdfsig with valgrind on that document
  https://paste.kde.org/pnfcsuhj8

Adding the people that have worked on signature handling to see if they can provide a fix.
Comment 3 Theofilos Intzoglou 2017-12-07 20:18:36 UTC
Created attachment 136041 [details] [review]
subjectdn_mem_alloc.patch

I attach a patch that handles auto removing memory allocated for subject DN as a proposed patch against master.
Comment 4 Albert Astals Cid 2018-07-22 22:19:52 UTC
Fixed with my last few commits to master.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.