b58e57
From ddd3d34e5c7979ca6f4a3a98a7d219a4ed3d98c2 Mon Sep 17 00:00:00 2001
b58e57
From: "djm@openbsd.org" <djm@openbsd.org>
b58e57
Date: Fri, 30 Dec 2016 22:08:02 +0000
b58e57
Subject: [PATCH] upstream commit
b58e57
b58e57
fix deadlock when keys/principals command produces a lot of
b58e57
output and a key is matched early; bz#2655, patch from jboning AT gmail.com
b58e57
b58e57
Upstream-ID: e19456429bf99087ea994432c16d00a642060afe
b58e57
---
b58e57
 auth2-pubkey.c | 8 +++++++-
b58e57
 1 file changed, 7 insertions(+), 1 deletion(-)
b58e57
b58e57
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
b58e57
index 20f3309e1..70c021589 100644
b58e57
--- a/auth2-pubkey.c
b58e57
+++ b/auth2-pubkey.c
b58e57
@@ -727,6 +727,9 @@ match_principals_command(struct passwd *user_pw, const struct sshkey *key)
b58e57
 
b58e57
 	ok = process_principals(f, NULL, pw, cert);
b58e57
 
b58e57
+	fclose(f);
b58e57
+	f = NULL;
b58e57
+
b58e57
 	if (exited_cleanly(pid, "AuthorizedPrincipalsCommand", command) != 0)
b58e57
 		goto out;
b58e57
 
b58e57
@@ -1050,6 +1053,9 @@ user_key_command_allowed2(struct passwd *user_pw, Key *key)
b58e57
 
b58e57
 	ok = check_authkeys_file(f, options.authorized_keys_command, key, pw);
b58e57
 
b58e57
+	fclose(f);
b58e57
+	f = NULL;
b58e57
+
b58e57
 	if (exited_cleanly(pid, "AuthorizedKeysCommand", command) != 0)
b58e57
 		goto out;
b58e57
 
b58e57