From nobody Tue Mar 14 17:29:38 2023 X-Original-To: dev-commits-src-all@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 4PbgWQ71RNz3yWLc; Tue, 14 Mar 2023 17:29:38 +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 4PbgWQ6bHVz3ByM; Tue, 14 Mar 2023 17:29:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678814978; 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=p3ech/v7br24gl+pK701JkgnM4oroCb9SmZL1fmvr6s=; b=BncZi3nEOnVX0b9ut0ngtValjrBOowNZ50jkDOZlXvbTcKTv/641yHouOL/HFlO/H84kEp iNy/K+J5Fn/+qZ2ZNyEOCJALCk8CPpX4PC/qX/lQEXWv1A9T9CFwam3brg/P4CX4Pgy8cr JB5HD/8PqIiEdQYqEGSeAyMTgKjYX2CHxOb3dSDIz/WfNaXs9Mk8VkVazhrCEwVAHKOXYy GxlilQ40lvIjMiMCcI7YiVSNFD3QUBT8gjC+mWtS/sorg98j8d/ymf/qKQUZ0OdyzdR08j k/gS9n9WEPbMDCKPwCkxLTJzYbFKIN09WO3a+ANhmEoQQcgKyJGuQkrY9KN37Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678814978; 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=p3ech/v7br24gl+pK701JkgnM4oroCb9SmZL1fmvr6s=; b=YMhzL69WBZU1Ts+4dsoUKxyYSrh+oqsXZf7OC+lXgMGI33e9AZcvee0jMiAdG4/Gt+5FYI CJ2UEUIEQpYDTF44jHowSMvpBS9sukTg0ddeSqDQC5awDAB5jGb6q7qWqYQcpVal9kl+jt BAnmySoz7SZBp0GyinwX8C+b0wmTQwCGPmfEsqSLrdA0zkNbk/8z4eeonp5zm669BDu52N mwRTGrQZYuTQkBFs9s0XM+7mIr2ubmdDrtoZxdMqt9WCT+WxvwSPw+3inXSQ4zl06++5Ys oQvAst1OyKdmQHS5hU2DJ2v2iw0JM13w9JFbyfqyjdZIg3JKZIgmh4z/zPyPpQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678814978; a=rsa-sha256; cv=none; b=Sb3VSLxHiSiEFFIjA1Mw7ZgjCKefwrR9WOSZwTLyPUyHrDdETHC844wXQv7KeJZl0v8CYL IcEdcUUnZXmdYT1yfKl3xEfFdgmk9TrBDX7xy4KeqzARI83N5sAYQeLrLLPwRVSxDJkTjF MCuHQQ/C2oSspIhHP8f9DHbzHYrUDSfH1KinotB5m76po7yjHGPJuDHzyxuVGy9+iEmzpS +cIsoYz+smsTgBn0WB4fqHMdcIYu76n7GmEuINWujyI3JGQ2ZJo4yocpbBGlW1KlmOqyUr pWgz0HEqFQKt8U0oukbx/pUArPiUllxv0na1vRCEe0aZILruAOfUFzQ16Pi2QA== 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 4PbgWQ5hwVzkV3; Tue, 14 Mar 2023 17:29:38 +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 32EHTcWZ056481; Tue, 14 Mar 2023 17:29:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32EHTcDk056480; Tue, 14 Mar 2023 17:29:38 GMT (envelope-from git) Date: Tue, 14 Mar 2023 17:29:38 GMT Message-Id: <202303141729.32EHTcDk056480@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: 19aba210e1a1 - main - ssh: fix leak and apply style(9) to hostname canonicalization List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 19aba210e1a1b5999bff10cccab5a277060c4d46 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=19aba210e1a1b5999bff10cccab5a277060c4d46 commit 19aba210e1a1b5999bff10cccab5a277060c4d46 Author: Ed Maste AuthorDate: 2023-02-08 13:16:53 +0000 Commit: Ed Maste CommitDate: 2023-03-14 17:16:57 +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 --- 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 21050ec342e0..7a44744e0029 100644 --- a/crypto/openssh/ssh.c +++ b/crypto/openssh/ssh.c @@ -1388,18 +1388,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); } }