Module Name:    src
Committed By:   agc
Date:           Fri May 21 06:53:51 UTC 2010

Modified Files:
        src/crypto/external/bsd/netpgp/dist/src/lib: netpgp.c

Log Message:
Protect against NULL pointers in key output in a different way - only
advance its counter if it's non-NULL.

Regression test for this is:

        netpgpkeys --list-key '\.de\>'

with my standard keyring (to list all keys which have at least one subuid
with a German email address).


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 \
    src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.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/netpgp.c
diff -u src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.54 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.55
--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.54	Thu May 20 14:43:42 2010
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c	Fri May 21 06:53:51 2010
@@ -34,7 +34,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: netpgp.c,v 1.54 2010/05/20 14:43:42 agc Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.55 2010/05/21 06:53:51 agc Exp $");
 #endif
 
 #include <sys/types.h>
@@ -600,7 +600,9 @@
 						"pub",
 						&key->key.pubkey, psigs);
 			}
-			pubs.c += 1;
+			if (pubs.v[pubs.c] != NULL) {
+				pubs.c += 1;
+			}
 			k += 1;
 		}
 	} while (key != NULL);
@@ -611,10 +613,8 @@
 			(pubs.c == 1) ? "" : "s");
 	}
 	for (k = 0 ; k < pubs.c ; k++) {
-		if (pubs.v[k]) {
-			(void) fprintf(fp, "%s%s", pubs.v[k], (k < pubs.c - 1) ? "\n" : "");
-			free(pubs.v[k]);
-		}
+		(void) fprintf(fp, "%s%s", pubs.v[k], (k < pubs.c - 1) ? "\n" : "");
+		free(pubs.v[k]);
 	}
 	free(pubs.v);
 	return pubs.c;

Reply via email to