From nobody Thu Dec 01 14:25:25 2022 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 4NNJJQ0bq6z4jLDT; Thu, 1 Dec 2022 14:25:26 +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 4NNJJQ018sz3rxP; Thu, 1 Dec 2022 14:25:26 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669904726; 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=+cMkCsQJpgE6fTEQDgNP7DY684DYi+cmC6Sb8881TYk=; b=Yl7WPpuThCZLNIahfaJpo3ZT0+rboG9BGQlFYmRnnQ0HaTW+8Ws+gP681MqNhATDsj16fg xxwd0GG57EyF9LRsGVzEvOM1hxpPu+MauO5IgOPA1Bhmn+sEpxrL5MPaOwUVBugq3AkmAh 8AGi8UXN09BPSptmVwlXlZ7i+vuBHRrjzH6F5LZRRmc0XOQ8lRflui1Zgy56JoUx5yCq8I 3MKpWVM2oIVNW40RsLyx4YQ4IfbAADSba3owPGJWnSwV+1PhifEb+lu5sgcJ9SJB0iXEuY fEo825VsVz54eLwl8rL70ikPZCK0V3iBcb5a0hOTGopzBck/V6xN99QGcA3hKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669904726; 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=+cMkCsQJpgE6fTEQDgNP7DY684DYi+cmC6Sb8881TYk=; b=Sz3tlesIg6WIpgAUKo1KOyo0LcE+aAkArs4PC6XgdcGPz6asKPw+7bz41EpPEKxMBscgA9 3NgM5TJQzI/yJUQ/AWji5s0K8qjCRhBShvwnFVzLwFgYDk+fUqwyLgYJhyVbELv0ytAAf0 5npF1K8hsGYRUeVd4K+JQu5H/hrUx6WbwuTzfjYH5+H5ICU0qc5aV8O2EOfL9pzKAC14SZ fckIV5mYxIqHwUN8/G7qm1SHns8Jho5L7KkKfkFAE/KzpJrO00os3foUIsMvjBUV6xV5b8 CiiUYSyIYQDv8wC1dbKEbyRItJOXNb2UUm6TZ5GWmbmtao5Blm05QZUOZr4pfw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669904726; a=rsa-sha256; cv=none; b=U4C0IJL1wiUPYp9BboJ3rhSskYVtx+dYAV23+48eDOzmxWu/4EZJfeUD5w/5y5c8VKIoC9 5w+ofFvS3u/3b2008kwved9GPJXq/d1JbXkV8mGc1gw4pGh/ORKy55a8RJKyUAj2cC1NjP dx1PRyyB4D97HNsGUsGgRzHWjk+YS+9jTvb2HisQDzA5av1E84pGfnTshbRjm4fCE1rqqD 06V4Bax6J/tHRueluG0nUXY8yChc4ffk/vfIOlllvY48lXca1sXMWwGvnqbIZq3K9RmvsK n8035ifi9FdEIVHI+eOmebnYazar7WULu+ywI2OH1DLW3SfcRSVZmAgOuHLryg== 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 4NNJJP68LXzgK7; Thu, 1 Dec 2022 14:25:25 +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 2B1EPPfc079060; Thu, 1 Dec 2022 14:25:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B1EPPRY079059; Thu, 1 Dec 2022 14:25:25 GMT (envelope-from git) Date: Thu, 1 Dec 2022 14:25:25 GMT Message-Id: <202212011425.2B1EPPRY079059@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Cy Schubert Subject: git: e7dcb18d5108 - stable/13 - heimdal: The version string must always contain a terminating NUL 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: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e7dcb18d51088654948840a66ad3864a66f1cb96 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=e7dcb18d51088654948840a66ad3864a66f1cb96 commit e7dcb18d51088654948840a66ad3864a66f1cb96 Author: Cy Schubert AuthorDate: 2022-11-21 15:33:08 +0000 Commit: Cy Schubert CommitDate: 2022-12-01 14:25:10 +0000 heimdal: The version string must always contain a terminating NUL Should the sender send a string without a terminating NUL, ensure that the NUL terminates the string regardless. And while at it only process the version string when bytes are returned. PR: 267884 Reported by: Robert Morris Differential Revision: https://reviews.freebsd.org/D37471 (cherry picked from commit d7e8666ffb9967a92709a2d2ded4d31568ab1473) --- crypto/heimdal/lib/krb5/recvauth.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/crypto/heimdal/lib/krb5/recvauth.c b/crypto/heimdal/lib/krb5/recvauth.c index 78e98a10fc1b..b63b28628395 100644 --- a/crypto/heimdal/lib/krb5/recvauth.c +++ b/crypto/heimdal/lib/krb5/recvauth.c @@ -75,7 +75,7 @@ krb5_recvauth_match_version(krb5_context context, const char *version = KRB5_SENDAUTH_VERSION; char her_version[sizeof(KRB5_SENDAUTH_VERSION)]; char *her_appl_version; - uint32_t len; + uint32_t len, bytes; u_char repl; krb5_data data; krb5_flags ap_options; @@ -139,15 +139,21 @@ krb5_recvauth_match_version(krb5_context context, N_("malloc: out of memory", "")); return ENOMEM; } - if (krb5_net_read (context, p_fd, her_appl_version, len) != len - || !(*match_appl_version)(match_data, her_appl_version)) { - repl = 2; - krb5_net_write (context, p_fd, &repl, 1); - krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS, - N_("wrong sendauth version (%s)", ""), - her_appl_version); - free (her_appl_version); - return KRB5_SENDAUTH_BADAPPLVERS; + if ((bytes = krb5_net_read (context, p_fd, her_appl_version, len))) { + /* PR/267884: String read must always conatain a terminating NUL */ + if (strnlen(her_appl_version, len) == len) + her_appl_version[len-1] = '\0'; + + if (bytes != len || + !(*match_appl_version)(match_data, her_appl_version)) { + repl = 2; + krb5_net_write (context, p_fd, &repl, 1); + krb5_set_error_message(context, KRB5_SENDAUTH_BADAPPLVERS, + N_("wrong sendauth version (%s)", ""), + her_appl_version); + free (her_appl_version); + return KRB5_SENDAUTH_BADAPPLVERS; + } } free (her_appl_version);