Module Name: src
Committed By: khorben
Date: Mon Feb 20 00:51:08 UTC 2017
Modified Files:
src/crypto/external/bsd/netpgp/dist/src/lib: keyring.c
Log Message:
Do not crash when listing keys without a keyring
To test: (with an empty ~/.gnupg)
$ netpgpkeys --import-key /dev/null
Submitted on tech-pkg@ as:
[PATCH 01/11] Do not crash when listing keys without a keyring
Different patch for the same issue.
To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 \
src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.50 src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.51
--- src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.50 Sat Jun 25 00:37:44 2011
+++ src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Mon Feb 20 00:51:08 2017
@@ -57,7 +57,7 @@
#if defined(__NetBSD__)
__COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: keyring.c,v 1.50 2011/06/25 00:37:44 agc Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.51 2017/02/20 00:51:08 khorben Exp $");
#endif
#ifdef HAVE_FCNTL_H
@@ -993,9 +993,12 @@ pgp_keyring_list(pgp_io_t *io, const pgp
{
pgp_key_t *key;
unsigned n;
+ unsigned keyc = (keyring != NULL) ? keyring->keyc : 0;
- (void) fprintf(io->res, "%u key%s\n", keyring->keyc,
- (keyring->keyc == 1) ? "" : "s");
+ (void) fprintf(io->res, "%u key%s\n", keyc, (keyc == 1) ? "" : "s");
+ if (keyring == NULL) {
+ return 1;
+ }
for (n = 0, key = keyring->keys; n < keyring->keyc; ++n, ++key) {
if (pgp_is_key_secret(key)) {
pgp_print_keydata(io, keyring, key, "sec",