Module Name:    src
Committed By:   rillig
Date:           Sat Oct  1 22:21:31 UTC 2022

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

Log Message:
netpgpkeys: properly terminate string before calling strdup

$ MALLOC_CONF=junk:true netpgpkeys \
    --export-key \
    --keyring=/usr/pkg/etc/gnupg/pkgsrc.gpg \
    b5952cabdd765a20

The above command printed "-----END PGP PUBLIC KEY BLOCK-----\r\n"
followed by "\xA5\xA5\xA5...".


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 \
    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.58 src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.59
--- src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c:1.58	Sat Aug 27 08:58:32 2022
+++ src/crypto/external/bsd/netpgp/dist/src/lib/keyring.c	Sat Oct  1 22:21:31 2022
@@ -57,7 +57,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: keyring.c,v 1.58 2022/08/27 08:58:32 rillig Exp $");
+__RCSID("$NetBSD: keyring.c,v 1.59 2022/10/01 22:21:31 rillig Exp $");
 #endif
 
 #ifdef HAVE_FCNTL_H
@@ -1159,6 +1159,7 @@ pgp_export_key(pgp_io_t *io, const pgp_k
 		pgp_write_xfer_seckey(output, keydata, passphrase,
 					strlen((char *)passphrase), 1);
 	}
+	pgp_memory_add(mem, "", 1);
 	cp = netpgp_strdup(pgp_mem_data(mem));
 	pgp_teardown_memory_write(output, mem);
 	return cp;

Reply via email to