Module Name:    src
Committed By:   rillig
Date:           Sat Aug 27 08:35:01 UTC 2022

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

Log Message:
netpgp: fix use after free when writing keyring

Same pattern as in the previous commit.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 \
    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.104 src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.105
--- src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c:1.104	Sat Aug 27 08:30:06 2022
+++ src/crypto/external/bsd/netpgp/dist/src/lib/netpgp.c	Sat Aug 27 08:35:01 2022
@@ -34,7 +34,7 @@
 
 #if defined(__NetBSD__)
 __COPYRIGHT("@(#) Copyright (c) 2009 The NetBSD Foundation, Inc. All rights reserved.");
-__RCSID("$NetBSD: netpgp.c,v 1.104 2022/08/27 08:30:06 rillig Exp $");
+__RCSID("$NetBSD: netpgp.c,v 1.105 2022/08/27 08:35:01 rillig Exp $");
 #endif
 
 #include <sys/types.h>
@@ -317,8 +317,8 @@ writekeyring(netpgp_t *netpgp, const cha
 
 	filename = keyringfile(netpgp, name);
 	if (!pgp_keyring_filewrite(keyring, noarmor, filename, passphrase)) {
-		free(filename);
 		(void) fprintf(stderr, "Can't write %s %s\n", name, filename);
+		free(filename);
 		return 0;
 	}
 	netpgp_setvar(netpgp, name, filename);

Reply via email to