[openssh-commits] [openssh] 86/87: upstream: regress test for properly-delimited %C token

git+noreply at mindrot.org git+noreply at mindrot.org
Fri Oct 30 20:22:03 AEDT 2026


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 0ce209a1ca57e97439af8d6ffbe3212586ccc032
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Fri Oct 30 08:43:39 2026 +0000

    upstream: regress test for properly-delimited %C token
    
    Anthropic ANT-2026-WLVAFTWQ
    
    OpenBSD-Regress-ID: e8c28119ec9bfb850a865d46b81071d05c4d639e
---
 regress/percent.sh | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/regress/percent.sh b/regress/percent.sh
index 337d9edf0..2fd00f6ac 100644
--- a/regress/percent.sh
+++ b/regress/percent.sh
@@ -1,4 +1,4 @@
-#	$OpenBSD: percent.sh,v 1.24 2026/10/03 05:08:49 dtucker Exp $
+#	$OpenBSD: percent.sh,v 1.25 2026/10/30 08:43:39 djm Exp $
 #	Placed in the Public Domain.
 
 tid="percent expansions"
@@ -122,7 +122,8 @@ for i in matchexec localcommand proxycommand remotecommand controlpath \
 	fi
 	# Matches implementation in readconf.c:ssh_connection_hash()
 	if [ ! -z "${OPENSSL_BIN}" ]; then
-		HASH=`printf "${HOSTNAME}127.0.0.1${PORT}${REMUSER}" |
+		HASH=`printf '%s\\0%s\\0%s\\0%s\\0%s\\0' \\
+		    "${HOSTNAME}" 127.0.0.1 "${PORT}" "${REMUSER}" "" |
 		    $OPENSSL_BIN sha1 | cut -f2 -d' '`
 		trial $i '%C' $HASH
 	fi
@@ -151,6 +152,17 @@ for i in matchexec localcommand proxycommand remotecommand controlpath \
 	fi
 done
 
+# %C must differ between destinations whose fields merely concatenate to the
+# same string, e.g. host 127.0.0.1 port 2222 vs. host 127.0.0.12 port 222.
+verbose $tid controlpath hash unique
+a=`${SSH} -F $OBJ/ssh_proxy -oControlPath=%C -oHostname=127.0.0.1 -p 2222 -G \
+    remuser at somehost | awk '$1=="controlpath"{print $2}'`
+b=`${SSH} -F $OBJ/ssh_proxy -oControlPath=%C -oHostname=127.0.0.12 -p 222 -G \
+    remuser at somehost | awk '$1=="controlpath"{print $2}'`
+if [ -z "$a" ] || [ "$a" = "$b" ]; then
+	fail "controlpath %C not unique: '$a' vs '$b'"
+fi
+
 # Subset of above since we don't expand shell-style variables on anything that
 # runs a command because the shell will expand those.
 FOO=bar

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list