Subject: | get_secret_keys(): Use of uninitialized value $expiration_date |
get_secret_keys() warns on 'Use of uninitialized value $expiration_date'
when it's processing a key which has no expiration date set.
How to reproduce:
1. Create a test key pair, do not set expiry date: 'gpg --gen-key'
2. Test with script:
-----
$ cat gnupg-test.pl
#!/usr/bin/perl
use strict;
use warnings FATAL => qw(all);
use GnuPG::Interface;
my $gnupg = GnuPG::Interface->new;
print $_->short_hex_id."\n" foreach ($gnupg->get_secret_keys);
-----
Example test script run and key details from gpg:
-----
$ ./gnupg-test.pl
Use of uninitialized value $expiration_date in string eq at
/usr/share/perl5/GnuPG/Interface.pm line 438, <GEN1> line 1.
Use of uninitialized value $expiration_date in string eq at
/usr/share/perl5/GnuPG/Interface.pm line 555, <GEN1> line 4.
81DDC625
$ gpg --list-secret-keys --with-colons --fixed-list-mode
--with-fingerprint 81DDC625
sec::4096:1:5D1AFE8981DDC625:1274642370::::::scESC::::
fpr:::::::::5ED0356C51BE7242126F28705D1AFE8981DDC625:
uid:::::1290146783::6AEE7A9CD5A744BC03551C641A0A0A509ED76735::Ville
Mattila <vm@iki.fi>:
ssb::4096:1:363AA660F50358AD:1274642370::::::e::::
-----
A (trivial) patch for
http://search.cpan.org/src/JESSE/GnuPG-Interface-0.44/lib/GnuPG/Interface.pm
is attached; fixes the problem for my specific case. Please note that
the same code seems to appear also on line 483 of GnuPG/Interface.pm
(signature and revocation processing?) - that might be broken, too?
Environment:
"This is perl, v5.10.1 (*) built for x86_64-linux-gnu-thread-multi"
"Linux liikkuva 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:02:55 UTC
2011 x86_64 x86_64 x86_64 GNU/Linux"
Subject: | gnupg-interface-no-key-expiry-date.patch |
--- GnuPG/Interface.pm.orig 2011-09-22 06:28:18.182124922 +0300
+++ GnuPG/Interface.pm 2011-09-22 06:28:14.982203738 +0300
@@ -435,7 +435,7 @@
# --fixed-list-mode uses epoch time for creation and expiration date strings.
# For backward compatibility, we convert them back using GMT;
my $expiration_date_string;
- if ($expiration_date eq '') {
+ if (defined $expiration_date && $expiration_date eq '') {
$expiration_date = undef;
} else {
$expiration_date_string = $self->_downrez_date($expiration_date);
@@ -552,7 +552,7 @@
) = @fields[ 1 .. 11 ];
my $expiration_date_string;
- if ($expiration_date eq '') {
+ if (defined $expiration_date && $expiration_date eq '') {
$expiration_date = undef;
} else {
$expiration_date_string = $self->_downrez_date($expiration_date);