Bug 699840

Summary: signing segfaults MuPDF
Product: MuPDF Reporter: Pablo Rodríguez <ghostscript>
Component: mupdfAssignee: MuPDF bugs <mupdf-bugs>
Status: RESOLVED FIXED    
Severity: major CC: tor.andersson
Priority: P4    
Version: master   
Hardware: PC   
OS: Linux   
Customer: Word Size: ---
Attachments: PDF document with signature field
Certificate with password "123456"

Description Pablo Rodríguez 2018-10-01 14:26:27 UTC
Created attachment 15715 [details]
PDF document with signature field

I have tried to sign the attached document (signature-field.pdf) with the attached certificate (JohnDoe.pfx) and I got the following segmentation fault.

Starting program: /usr/bin/mupdf-gl a.pdf
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
error: cannot create appearance stream for Sig widgets
warning: cannot create appearance stream
error: cannot create appearance stream for Sig widgets
warning: cannot create appearance stream
error: cannot create appearance stream for Sig widgets
warning: cannot create appearance stream

Program received signal SIGSEGV, Segmentation fault.
0x00000000004947af in pdf_sign_signature (ctx=0xce3ca0, doc=0xecd320, widget=0x0, signer=0x1293140) at source/pdf/pdf-signature.c:75
75			pdf_obj *wobj = ((pdf_annot *)widget)->obj;
(gdb) bt
#0  0x00000000004947af in pdf_sign_signature (ctx=0xce3ca0, doc=0xecd320, widget=0x0, signer=0x1293140) at source/pdf/pdf-signature.c:75
#1  0x000000000040f576 in do_sign () at platform/gl/gl-form.c:25
#2  0x000000000040f6b0 in cert_password_dialog () at platform/gl/gl-form.c:59
#3  0x0000000000415296 in run_main_loop () at platform/gl/gl-main.c:1444
#4  0x0000000000415f4f in on_mouse (button=<optimized out>, action=<optimized out>, x=<optimized out>, y=<optimized out>) at platform/gl/gl-ui.c:323
#5  0x0000000000573a12 in fgPlatformProcessSingleEvent () at thirdparty/freeglut/src/x11/fg_main_x11.c:1144
#6  0x000000000056f113 in glutMainLoopEvent () at thirdparty/freeglut/src/fg_main.c:449
#7  0x000000000056f25d in glutMainLoop () at thirdparty/freeglut/src/fg_main.c:489
#8  0x000000000040995b in main (argc=<optimized out>, argv=0x7fffffffe1e8) at platform/gl/gl-main.c:1578

Just in case it helps,

Pablo
Comment 1 Pablo Rodríguez 2018-10-01 14:27:26 UTC
Created attachment 15716 [details]
Certificate with password "123456"
Comment 2 Tor Andersson 2018-11-07 19:16:14 UTC
commit 68840d4a34e1e56ea9130158e8e163fb60550db4
Author: Tor Andersson <tor.andersson@artifex.com>
Date:   Wed Nov 7 19:44:55 2018 +0100

    Fix 699840: Use saved sig_widget pointer to sign signatures, not selected_annot.