From nobody Mon Jun 5 18:11:20 2023 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4QZhWD3s1jz4ZmZR; Mon, 5 Jun 2023 18:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QZhWD3Kmsz3lN9; Mon, 5 Jun 2023 18:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685988680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PdlMYyyWYOQxk33oMmYu9a7mxBrgHVw7CAhKettJlTo=; b=S/DsaNXSZt/Pfue9Del47Iir2WJqNFpU+4iREISKr6dzVrTqST5B2fwg33u4g1qnF9iUN7 ljiCi2MXrKOCF2eR/LNHHWihXBtj8VhWQ3EqibfALxtSgoogWar8JKlUecOI0GybYxieou oJs7DuYIfhPp7U/k5In34DqsGasmhHgAXCEsJx6wXLvlqohkDq3CtvhsO95BOnXs2h+o25 5qdipF9OuJOWIYBhNxRCaHOJOcdglrUKc/ATM+WvQh0ikqc4pQQFnjhaxb6hJs40JZUjYI tRVrc8ffQZ6qgmSlXIJCNgYYeB1+lOJuPrif926s9VTbAKQ2iRcHoneH9HrOXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685988680; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=PdlMYyyWYOQxk33oMmYu9a7mxBrgHVw7CAhKettJlTo=; b=rioms5+K37pgWglyiGxgQ94Llyn2sB3OjuVOl93Q3qVOmXSYl4PixSGYxEA9x8dQWSeaJ5 OUcXMWHDWqlYwXwllNyBvdJ2DobIGJKvFEXL3CDLe1pc7xfvE9yhQSToOpgkMhPXBoT6vx Lav6vYrsRWeH5YlLd5AQpmq1fkQHGkkc5jIuwBtB31XSxhWuSvRIuRVkruF3Eme61faXh4 I6OHaBwYFGzMxq+NQBLKJDdM/XwXA5gB9yHguEI4Ut94mxKAwkb2Y4gu2RdLvwqBsd5VIY B17Lcabanr/7inObhuhGKwUm7IehoK8G4OTq+Vu9GhltSUFg7kNCDSNkl/CiBA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685988680; a=rsa-sha256; cv=none; b=sJD9phZa1qFr1V9LaoDNwbi4tC8KW6GG29691jS9U2Iw9OujFwIBqrO+HFe6kCzQLT7YsC hd5660J6QNEfYkdpiTQhKsGtRU19gxOxJZWfxauLaizLSnsklLGS3cYFochcKEXBdFqyBK I2Yn76KsHZRMKQ8BcEZcEX24XcZbgb3BYHWZR7vuHkVXYAzYceKScEl3U+sEM863RoUW4M 1ZIbTuO8rwIVNuE0AW2sXPRWXUXTYXMBqduWPxxebQ0SEsmYYiX8/TZg6EJM+z1NGOfGxf rpoXjd4TVDRTkRjg4MXCd9R/j6YArcZemJCmm9LbTDWbxSMsVN/ZvcTS2VLd+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QZhWD2Ql2zxwW; Mon, 5 Jun 2023 18:11:20 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 355IBKHf081540; Mon, 5 Jun 2023 18:11:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 355IBK7U081539; Mon, 5 Jun 2023 18:11:20 GMT (envelope-from git) Date: Mon, 5 Jun 2023 18:11:20 GMT Message-Id: <202306051811.355IBK7U081539@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ed Maste Subject: git: 792d3f16868e - stable/13 - ssh: fix leak and apply style(9) to hostname canonicalization List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 792d3f16868e5f79ab8b11803340251371515f0a Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=792d3f16868e5f79ab8b11803340251371515f0a commit 792d3f16868e5f79ab8b11803340251371515f0a Author: Ed Maste AuthorDate: 2023-02-08 13:16:53 +0000 Commit: Ed Maste CommitDate: 2023-06-05 16:03:51 +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) --- 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 268781518b8c..883406f7b8f9 100644 --- a/crypto/openssh/ssh.c +++ b/crypto/openssh/ssh.c @@ -1396,18 +1396,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); } }