Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Jun 2023 19:06:52 GMT
From:      Ed Maste <emaste@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 77d002b9cbf4 - stable/12 - ssh: fix leak and apply style(9) to hostname canonicalization
Message-ID:  <202306051906.355J6q8D085712@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=77d002b9cbf49168ba6261b5dc84b8e694c24b20

commit 77d002b9cbf49168ba6261b5dc84b8e694c24b20
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-02-08 13:16:53 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-06-05 19:05:32 +0000

    ssh: fix leak and apply style(9) to hostname canonicalization
    
    Fixes:          bf2e2524a2ce ("ssh: canonicize the host name before...")
    Fixes:          3e74849a1ee2 ("ssh: canonicize the host name before...")
    Reviewed by:    rew
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D38441
    
    (cherry picked from commit 19aba210e1a1b5999bff10cccab5a277060c4d46)
    (cherry picked from commit 792d3f16868e5f79ab8b11803340251371515f0a)
---
 crypto/openssh/ssh.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/crypto/openssh/ssh.c b/crypto/openssh/ssh.c
index c5a4326bd1c6..b058e8349c63 100644
--- a/crypto/openssh/ssh.c
+++ b/crypto/openssh/ssh.c
@@ -1397,18 +1397,21 @@ main(int ac, char **av)
 	cinfo->locuser = xstrdup(pw->pw_name);
 
 	/* Find canonic host name. */
-	if (strchr(host, '.') == 0) {
+	if (strchr(host, '.') == NULL) {
 		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)
+			if (ai->ai_canonname != NULL) {
+				free(host);
 				host = xstrdup(ai->ai_canonname);
+			}
 			freeaddrinfo(ai);
 		}
 	}



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