Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/netpgp/dist/src/lib Do not crash when li...



details:   https://anonhg.NetBSD.org/src/rev/14ec06fac145
branches:  trunk
changeset: 821857:14ec06fac145
user:      khorben <khorben%NetBSD.org@localhost>
date:      Mon Feb 20 00:51:08 2017 +0000

description:
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.

diffstat:

 crypto/external/bsd/netpgp/dist/src/lib/keyring.c |  9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 6eb3647f418a -r 14ec06fac145 crypto/external/bsd/netpgp/dist/src/lib/keyring.c
--- a/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Mon Feb 20 00:33:53 2017 +0000
+++ b/crypto/external/bsd/netpgp/dist/src/lib/keyring.c Mon Feb 20 00:51:08 2017 +0000
@@ -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_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",



Home | Main Index | Thread Index | Old Index