git: 6dca51b9f32d - stable/13 - ssh-keysign: fix double free in error path

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 07 Oct 2022 01:39:44 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=6dca51b9f32dd3f6a0dd58a0f1525db3d27f485d

commit 6dca51b9f32dd3f6a0dd58a0f1525db3d27f485d
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2022-10-04 20:34:15 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2022-10-07 01:39:00 +0000

    ssh-keysign: fix double free in error path
    
    From OpenSSH-portable commit 141535b904b6, OpenBSD commit 3d21aa127b1f.
    
    MFC after:              3 days
    
    (cherry picked from commit 963c7b084b8bf2397deced4f568b976a42611910)
---
 crypto/openssh/ssh-keysign.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/crypto/openssh/ssh-keysign.c b/crypto/openssh/ssh-keysign.c
index c52321e220e7..b989f5e941ad 100644
--- a/crypto/openssh/ssh-keysign.c
+++ b/crypto/openssh/ssh-keysign.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-keysign.c,v 1.70 2022/01/06 22:00:18 djm Exp $ */
+/* $OpenBSD: ssh-keysign.c,v 1.71 2022/08/01 11:09:26 djm Exp $ */
 /*
  * Copyright (c) 2002 Markus Friedl.  All rights reserved.
  *
@@ -155,9 +155,7 @@ valid_request(struct passwd *pw, char *host, struct sshkey **ret, char **pkalgp,
 
 	debug3_f("fail %d", fail);
 
-	if (fail)
-		sshkey_free(key);
-	else {
+	if (!fail) {
 		if (ret != NULL) {
 			*ret = key;
 			key = NULL;