Page MenuHome GnuPG

gpg --list-secret-keys: Segmentation fault
Closed, ResolvedPublic

Description

When I run gpg --list-secret-keys I get one key listed and then a
segmentation fault.

I am running GnuPG 1.4.10-1 on Debian unstable (amd64).

I tried getting a backtrace:

asjo@topper:~$ gdb --args gpg --list-secret-keys
GNU gdb (GDB) 6.8.50.20090628-cvs-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(no debugging symbols found)
(gdb) run
Starting program: /usr/bin/gpg --list-secret-keys
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
(no debugging symbols found)
/home/asjo/.gnupg/secring.gpg
-----------------------------
sec#  1024D/EFCFE0B3 1999-09-17
uid                  Adam Sjøgren <asjo@koldfront.dk>
uid                  Adam Sjøgren <asjo@asjo.org>
uid                  Adam Sjøgren <asjo@diku.dk>
uid                  [jpeg image of size 2455]

Program received signal SIGSEGV, Segmentation fault.
0x00000000004221db in ?? ()
(gdb) bt
#0  0x00000000004221db in ?? ()
#1  0x0000000000465825 in ?? ()
#2  0x0000000000465a99 in ?? ()
#3  0x0000000000475794 in ?? ()
#4  0x000000000042d216 in ?? ()
#5  0x000000000042d5a1 in ?? ()
#6  0x000000000042ea9b in ?? ()
#7  0x000000000040a628 in ?? ()
#8  0x00007ffff6e245c6 in __libc_start_main () from /lib/libc.so.6
#9  0x00000000004043d9 in ?? ()
#10 0x00007fffffffe298 in ?? ()
#11 0x000000000000001c in ?? ()
#12 0x0000000000000002 in ?? ()
#13 0x00007fffffffe5af in ?? ()
#14 0x00007fffffffe5bc in ?? ()
#15 0x0000000000000000 in ?? ()
(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
asjo@topper:~$ dpkg -l gnupg
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                 Version              Description

+++-====================-====================-========================================================

ii  gnupg                1.4.10-1             GNU privacy guard - a free PGP

replacement

asjo@topper:~$

But as the package in Debian has stripped binaries the above is light
on details, I thought I would try and build a package locally with
debug, noopt and nostrip and try again; this is the result of that:

asjo@topper:~$ gdb --args gpg --list-secret-keys
GNU gdb (GDB) 6.8.50.20090628-cvs-debian
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
(gdb) run
Starting program: /usr/bin/gpg --list-secret-keys
/home/asjo/.gnupg/secring.gpg
-----------------------------
sec#  1024D/EFCFE0B3 1999-09-17
uid                  Adam Sjøgren <asjo@koldfront.dk>
uid                  Adam Sjøgren <asjo@asjo.org>
uid                  Adam Sjøgren <asjo@diku.dk>
uid                  [jpeg image of size 2455]

Program received signal SIGSEGV, Segmentation fault.
0x0000000000428533 in keyid_from_pk (pk=0x0, keyid=0x7fffffffd840) at

../../g10/keyid.c:320

320       if( pk->keyid[0] || pk->keyid[1] )
(gdb) bt
#0  0x0000000000428533 in keyid_from_pk (pk=0x0, keyid=0x7fffffffd840) at

../../g10/keyid.c:320

#1  0x000000000047b2e0 in get_validity (pk=0x0, uid=0x738c60) at

../../g10/trustdb.c:1085

#2  0x000000000047b57c in get_validity_info (pk=0x0, uid=0x738c60) at

../../g10/trustdb.c:1185

#3  0x0000000000490833 in show_photos (attrs=0x738c40, count=1, pk=0x0,

sk=0x735320, uid=0x738c60)

    at ../../g10/photoid.c:307
#4  0x0000000000437197 in list_keyblock_print (keyblock=0x737770, secret=1,

fpr=0, opaque=0x0)

    at ../../g10/keylist.c:857
#5  0x0000000000438eca in list_keyblock (keyblock=0x737770, secret=1, fpr=0,

opaque=0x0)

    at ../../g10/keylist.c:1457
#6  0x0000000000435f98 in list_all (secret=1) at ../../g10/keylist.c:445
#7  0x00000000004353fb in secret_key_list (list=0x0) at ../../g10/keylist.c:116
#8  0x000000000040a854 in main (argc=0, argv=0x7fffffffe2b8) at

../../g10/gpg.c:3593

(gdb) quit
The program is running.  Quit anyway (and kill it)? (y or n) y
asjo@topper:~$ dpkg -l gnupg
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Cfg-files/Unpacked/Failed-cfg/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                 Version              Description

+++-====================-====================-========================================================

ii  gnupg                1.4.10-1koldfront1   GNU privacy guard - a free PGP

replacement

asjo@topper:~$

I am using an OpenPGP-card (from FSFE), and I have an old 1024-bit DSA
key that I set up using the instructions on setting up the card with
subkeys on fsfe.org¹. Recently I created a new 4096-bit RSA key, and
followed the same instructions, replacing the subkeys on the card. I
also have a third key that I use for signing packages in my local .deb
repository.

I hope this is sufficient information, otherwise let me know what I
should do/provide, and I'll try.

Thanks!

 Adam

¹: http://wiki.fsfe.org/Card_howtos/Card_with_subkeys_using_backups

Event Timeline

Please try this patch.

  • g10/trustdb.c (revision 5139)

+++ g10/trustdb.c (working copy)
@@ -1182,6 +1182,9 @@
{

int trustlevel;

+ if (!pk)
+ return '?'; /* Just in case a NULL PK is passed. */
+

trustlevel = get_validity (pk, uid);
if( trustlevel & TRUST_FLAG_REVOKED )
   return 'r';

@@ -1193,6 +1196,9 @@
{

int trustlevel;

+ if (!pk)
+ return "err"; /* Just in case a NULL PK is passed. */
+

trustlevel = get_validity (pk, uid);
if( trustlevel & TRUST_FLAG_REVOKED )
  return _("revoked");

The patch fixes the segmentation fault:

$ gpg --list-secret-keys

/home/asjo/.gnupg/secring.gpg

sec# 1024D/EFCFE0B3 1999-09-17
uid Adam Sjøgren <asjo@koldfront.dk>
uid Adam Sjøgren <asjo@asjo.org>
uid Adam Sjøgren <asjo@diku.dk>
uid [jpeg image of size 2455]
ssb> 1024R/08BC6475 2009-03-01
ssb> 1024R/51F52217 2009-03-01
ssb> 1024R/D7504C87 2009-03-01
ssb# 2048g/71D0CAF2 1999-09-17

sec# 4096R/21BDE416 2009-09-04
uid Adam Sjøgren <asjo@koldfront.dk>
uid Adam Sjøgren <asjo@asjo.org>
uid Adam Sjøgren <asjo@kammeratadam.dk>
ssb> 1024R/1E65DD19 2009-09-04
ssb> 1024R/321C353E 2009-09-04

sec 4096R/1717F8C3 2009-08-03
uid koldfront unofficial Debian package repository
<repo@koldfront.dk>

$

Thanks!

Commited to all branches. Thanks.

werner claimed this task.