summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorDamien Miller <djm@cvs.openbsd.org>2023-11-15 23:03:39 +0000
committerDamien Miller <djm@cvs.openbsd.org>2023-11-15 23:03:39 +0000
commit771aa9953ba48ab106ea44949e4384ae43bffa2c (patch)
tree600ef702b6dcb12ba199e0d6c49b638d730e71e4 /usr.bin
parenta74b27860b3dae769fff39f8f8ee791a8aea67eb (diff)
when connecting via socket (the default case), filter addresses by
AddressFamily if one was specified. Fixes the case where, if CanonicalizeHostname is enabled, ssh may ignore AddressFamily. bz5326; ok dtucker
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/sshconnect.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/ssh/sshconnect.c b/usr.bin/ssh/sshconnect.c
index a0ff055181d..a47c8f76bd2 100644
--- a/usr.bin/ssh/sshconnect.c
+++ b/usr.bin/ssh/sshconnect.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sshconnect.c,v 1.363 2023/03/10 07:17:08 dtucker Exp $ */
+/* $OpenBSD: sshconnect.c,v 1.364 2023/11/15 23:03:38 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -459,6 +459,14 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop,
errno = oerrno;
continue;
}
+ if (options.address_family != AF_UNSPEC &&
+ ai->ai_family != options.address_family) {
+ debug2_f("skipping address [%s]:%s: "
+ "wrong address family", ntop, strport);
+ errno = 0;
+ continue;
+ }
+
debug("Connecting to %.200s [%.100s] port %s.",
host, ntop, strport);