summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorvangyzen <vangyzen@FreeBSD.org>2015-07-21 14:36:33 +0000
committervangyzen <vangyzen@FreeBSD.org>2015-07-21 14:36:33 +0000
commit4b34a47d4c288297f05354d6de76bc6ce6c25837 (patch)
treeb5ee7eb0771fbca73508806a3aed59f912c473d2 /crypto
parentdbae220f096177759ed45c8e9566b50f3fcdfe80 (diff)
downloadFreeBSD-src-4b34a47d4c288297f05354d6de76bc6ce6c25837.zip
FreeBSD-src-4b34a47d4c288297f05354d6de76bc6ce6c25837.tar.gz
MFC r285642
ssh: canonicize the host name before looking it up in the host file Re-apply r99054 by des in 2002. This was accidentally dropped by the update to OpenSSH 6.5p1 (r261320). This change is actually taken from r387082 of ports/security/openssh-portable/files/patch-ssh.c Differential Revision: https://reviews.freebsd.org/D3103 PR: 198043 Approved by: re (gjb), kib (mentor) Sponsored by: Dell Inc. Relnotes: yes
Diffstat (limited to 'crypto')
-rw-r--r--crypto/openssh/ssh.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/crypto/openssh/ssh.c b/crypto/openssh/ssh.c
index eb69b72..1c0784a 100644
--- a/crypto/openssh/ssh.c
+++ b/crypto/openssh/ssh.c
@@ -1001,6 +1001,23 @@ main(int ac, char **av)
shorthost[strcspn(thishost, ".")] = '\0';
snprintf(portstr, sizeof(portstr), "%d", options.port);
+ /* Find canonic host name. */
+ if (strchr(host, '.') == 0) {
+ struct addrinfo hints;
+ struct addrinfo *ai = NULL;
+ int errgai;
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = options.address_family;
+ hints.ai_flags = AI_CANONNAME;
+ hints.ai_socktype = SOCK_STREAM;
+ errgai = getaddrinfo(host, NULL, &hints, &ai);
+ if (errgai == 0) {
+ if (ai->ai_canonname != NULL)
+ host = xstrdup(ai->ai_canonname);
+ freeaddrinfo(ai);
+ }
+ }
+
if (options.local_command != NULL) {
debug3("expanding LocalCommand: %s", options.local_command);
cp = options.local_command;
OpenPOWER on IntegriCloud