From nobody Thu Dec 1 14:26:03 2022 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 4NNJK76XkFz4jLSJ; Thu, 1 Dec 2022 14:26:03 +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 4NNJK75yc6z3vSZ; Thu, 1 Dec 2022 14:26:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669904763; 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=TA22Ei6Ix35uReNoS0Bnrsvr8KXEDXTzmE9elpM3o+g=; b=CqIW8CvYqqDllJgSAXSqzOYYLKa6b1tPpZLiGbyoKLI5cSZMvpd/Av9Wtq/7/2hnzSUYsO 1v/GB+jTEA3MI7AiIznsiTYb4Jsardb5h/dMKnZ5l/yzOgO4SVGAuj0gmaN+M3pCEtm6F4 8bHdVFwF2x67Z4njuia/AjPhaTJtHw4W+lCmA5y3noNTzhm3idObQWeov4ssQ8IPBhpPw8 X1dMT/Mi+BC462bDoaJw+UanRMTvC41cka6yn9gPR7rW1x2+wtwoPC5+s8qvGYLQ9wmaLz pMzfuseDwh45HR5J3ySudtq+IdG+B7VQ3JLK5IZUC0Ek1iCiPHRXWjafzSl8gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1669904763; 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=TA22Ei6Ix35uReNoS0Bnrsvr8KXEDXTzmE9elpM3o+g=; b=Z7mx9Eh8KlJ6cfBxoHnuh9wW5pEsh/SMih6eT6cUY2PZiuT0al4/eKQ3BlySq/VCRx6GV8 gUjups11y5XNoIK+jx0jVZSPC3kGCSGbpmIeRDJG6nW92L3PHHV7sAZLe0evsSnJTcbF7n Bdcd0uA17Q5lyT6jCg2uS81ime0CBYGrz+1Fye1FVDLrH4GAI407+xsRTPCI2PyGWNH9sX GeIIgGvllBTah9eckvcd7bky05kNsF7qA0PDDrtSM6ReepmkbTHFMwj/6sGbbTVCS9AbzJ bdRst2p5CcLQg1q5Y2C/kl9YHWdhvhPx72nRk0O5rfM2GM/Q1OxDaIoDBSOTXg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1669904763; a=rsa-sha256; cv=none; b=koyLpOVkUbACearRpZpWcb4CSGRKKmYte5EOFg7WcHWhGpG3F+gaXfbkYgsYm81Rhj9RRI s7PlK/Ffu+5IFrOcCipd9P/yBYzToRdTXCLLcaSH48edSaVftUeHbFnvzlAT8mDSlwYx+w D+Gwr/UyjH9PV31qdDvyuCfPr2gStCyo6d/o5v8iClHaQVz9SaCZQuc+1jL00hBSfc25co z+VaaNgKi7OSqk5qhZ8vG60HfDBNHXUSp7f2Vcc50vG11UUMOtYo4msbUbBsDR3Y4eJrNo wHmgJ1J4cmd/vn9vgF+Egg4QFfWdRBm19t2IN8cKd7LBboofl136vD9Krqjr6g== 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 4NNJK750bkzfv6; Thu, 1 Dec 2022 14:26:03 +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 2B1EQ3TM079581; Thu, 1 Dec 2022 14:26:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2B1EQ327079580; Thu, 1 Dec 2022 14:26:03 GMT (envelope-from git) Date: Thu, 1 Dec 2022 14:26:03 GMT Message-Id: <202212011426.2B1EQ327079580@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: 8d3c6e82cdca - stable/12 - heimdal: The version string must always contain a terminating NUL 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: cy X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: 8d3c6e82cdcac5fa31836df6d3d067efd2e0e3bc Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by cy: URL: https://cgit.FreeBSD.org/src/commit/?id=8d3c6e82cdcac5fa31836df6d3d067efd2e0e3bc commit 8d3c6e82cdcac5fa31836df6d3d067efd2e0e3bc Author: Cy Schubert AuthorDate: 2022-11-21 15:33:08 +0000 Commit: Cy Schubert CommitDate: 2022-12-01 14:25:52 +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);