From 9517cc58577f85a0ba5f8bb46778dff625f0688f Mon Sep 17 00:00:00 2001
From: "djm@openbsd.org" <djm@openbsd.org>
Date: Tue, 24 Sep 2024 02:28:17 +0000
Subject: [PATCH] upstream: some extra paranoia, reminded by jsg@
 
Conflict:NA
Reference:https://anongit.mindrot.org/openssh.git/commit/9517cc58577f85a0ba5f8bb46778dff625f0688f

---
 ssh-agent.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ssh-agent.c b/ssh-agent.c
index cc58e6e..3d685e9 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -1578,6 +1578,10 @@ process_ext_session_bind(SocketEntry *e)
 		error_fr(r, "parse");
 		goto out;
 	}
+	if (sshbuf_len(sid) > AGENT_MAX_SID_LEN) {
+		error_f("session ID too long");
+		goto out;
+	}
 	if ((fp = sshkey_fingerprint(key, SSH_FP_HASH_DEFAULT,
 	    SSH_FP_DEFAULT)) == NULL)
 		fatal_f("fingerprint failed");
-- 
2.43.0

