Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jul 2015 18:54:39 +0000 (UTC)
From:      Eric van Gyzen <vangyzen@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r285763 - stable/9/crypto/openssh
Message-ID:  <201507211854.t6LIsdTh001365@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: vangyzen
Date: Tue Jul 21 18:54:38 2015
New Revision: 285763
URL: https://svnweb.freebsd.org/changeset/base/285763

Log:
  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:    kib (mentor)
  Sponsored by:   Dell Inc.
  Relnotes:       yes

Modified:
  stable/9/crypto/openssh/ssh.c
Directory Properties:
  stable/9/crypto/openssh/   (props changed)

Modified: stable/9/crypto/openssh/ssh.c
==============================================================================
--- stable/9/crypto/openssh/ssh.c	Tue Jul 21 18:38:31 2015	(r285762)
+++ stable/9/crypto/openssh/ssh.c	Tue Jul 21 18:54:38 2015	(r285763)
@@ -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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201507211854.t6LIsdTh001365>