From nobody Wed Jun 05 02:41:03 2024 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 4VvBXv5GHTz5NNst; Wed, 05 Jun 2024 02:41: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 4VvBXv4hWmz4dJk; Wed, 5 Jun 2024 02:41:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717555263; 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=RPS10YUGnNamBsMBKulp+pZGXyg/if3s+VhoKQWDn3g=; b=y0v/5trgMily7cJprt8+/e51LfEDhz22QoiSKL0uvIw3KTz8CWLMDN+sPXGv0EN4oYpX3a JDA7XzSYIF+6AykM7wrZc+sZ41DPPHsl1UGO8Ewt7J85NQ+qPMpktRbEpHcj/lXRTQpWfO QphdgNsAI9fp5b7W+IIoAaA5lRI/7DdYgSJ+45GfGzaGebQ8HT3ol8IBbXj3m9XX8GiU9d nx0KVZK0brLPcCD4Ql1cwdQI2Wl5wn2Y9FuPLZW3OQpp/RZTROxGfgRI0EyQRwVee2Rv4o L1DHwUI8XzoUd8xHMJdyfJhmanEswxvm6YsD7uw83D/uXY1z4ADmISFbAEAwUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717555263; a=rsa-sha256; cv=none; b=GoUI7Lm9YEMi9EHaSu7YHojjfcupyS2LW+fIL2mpaZcLDWQR/EC7hJYxB3q+bvqEH/i18i 5ISD0N0pyftjAYSnjDMLPzdGS/hKoPkmLHPToni/Jd+hL5fwgaTmAACsayxmOSO8T7l19s u7qFRz1e5KW+eNGRNFOCQajx+fyoltz9qcXPrkmioiYLUOhJOtjkfdclEsjZkQFQKTHhWP BcJTckeehY+4swPcXDvkNtGlXiWNCn7p8Xw2Nly2vi9C/0eSZuVi15CNT33onzWq6aIRde kMRNhWisrkNepMgEHOaNGHDWLXoUtjFzyRChDheuXBhARNr3RyUOQ8dk7VBpdQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717555263; 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=RPS10YUGnNamBsMBKulp+pZGXyg/if3s+VhoKQWDn3g=; b=vW0g+C6zYuvU3cKLFOGItM4rZ3fjWqnt6sODFR8oJsQUGs9hy98eV6YS+vEJSLeoqjbl7Z yq45/rhWbhpNgLd0AiNKmr5Nqb6JIoSFloKzmWSYfOFqfAwJHRH5iKMmVX7RIPCMfAqqma pVzlJ1evHSurAIvdsN6LDtc5nTxFDjk7AlNxiVDeE/zsBalal43G4TSktKo2X9uRkr6u9d afvsiSX5TCzwG6JhloGyWHlN7cJmhLCA9RyzN2H9dcTIw0PeFmZlt7JCLuJNZZxrXUvtnI APBA+DkjZYjFbiLQthLJ9zLpm0hUG35nSw+N5ymgStHsGD3IVW5ak0dPD7VqJQ== 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 4VvBXv4HRJzkJy; Wed, 5 Jun 2024 02:41:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 4552f3MD042491; Wed, 5 Jun 2024 02:41:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 4552f399042488; Wed, 5 Jun 2024 02:41:03 GMT (envelope-from git) Date: Wed, 5 Jun 2024 02:41:03 GMT Message-Id: <202406050241.4552f399042488@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Enji Cooper Subject: git: 77c04f3eb12a - main - radlib: fix a memory leak in `is_valid_request` 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: ngie X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 77c04f3eb12a560eb61252c817e4147bc0178e43 Auto-Submitted: auto-generated The branch main has been updated by ngie: URL: https://cgit.FreeBSD.org/src/commit/?id=77c04f3eb12a560eb61252c817e4147bc0178e43 commit 77c04f3eb12a560eb61252c817e4147bc0178e43 Author: Enji Cooper AuthorDate: 2024-06-04 20:01:55 +0000 Commit: Enji Cooper CommitDate: 2024-06-05 02:40:55 +0000 radlib: fix a memory leak in `is_valid_request` Call `HMAC_CTX_free` if returning early from `is_valid_request` when processing `Message-Authenticator` tags. Reported by: Coverity MFC after: 1 week Fixes: 8d5c7813061d ("libradius: Fix input validation bugs") Differential Revision: https://reviews.freebsd.org/D45488 --- lib/libradius/radlib.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/libradius/radlib.c b/lib/libradius/radlib.c index c7d18227021e..f45eb923774b 100644 --- a/lib/libradius/radlib.c +++ b/lib/libradius/radlib.c @@ -320,8 +320,10 @@ is_valid_request(struct rad_handle *h) hctx = HMAC_CTX_new(); while (pos < len - 2) { alen = h->in[pos + 1]; - if (alen < 2) + if (alen < 2) { + HMAC_CTX_free(hctx); return (0); + } if (h->in[pos] == RAD_MESSAGE_AUTHENTIC) { if (len - pos < MD5_DIGEST_LENGTH + 2) { HMAC_CTX_free(hctx);