From nobody Thu Apr 11 13:25:04 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 4VFgRP0BKsz5HQfc; Thu, 11 Apr 2024 13:25:05 +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 4VFgRN5Vx5z57hQ; Thu, 11 Apr 2024 13:25:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1712841904; 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=VhOfHe/mFdBp0gxT+q2Vugw7yILHoAKKUsV0JX48a6I=; b=F2L9mPdo8y1y+EhgXJP/RKmlKISbm4+1+BH131GJM6IV3eMz/VO7KGpXfbLrnDhosJCcJ9 +pDMQ+jQHt/htUp2/GFQ0F4OPtOl6rd772ZIWaQSpzSi8u5MuAzWIBHw5MOhTS2n7KVy2z /SKOIPXCBiwxAXMm4pabQhdlwYqJFlfRD4LDyMpYKpKpXql21O6UiiGBb5mTXpgLEMi9kA Zj4HmzImVANSbd9Nc0fbye4OrJ8NnL1lpaxwXWNveXPQNCfu3sXjvcgWwrGsoOGXOVfbe9 gKQlEvgO+6gxHLzog7Q8qeFMtd7Aifgp/Di4ZG7CnAn7tadrCfsj06v49RdBEw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1712841904; a=rsa-sha256; cv=none; b=t7R726adCE3Q0RlMslRjIK4APev+LhfXjIcDC4wDozW1RlJ4qnaPKA7GYlatsSx2qZfv0I IyR0d/4G6oyKlIz0oCpgwmrxp1oDg7UCvyMRrRiil4mqTx4KqcBzKB2zaCFQuu10iNJ6xy WtRQ7Q7Ud+kQmjA9/epgVGxGWKyHphoucCtM6/hX/TAKVX3TpJUyBPFKmjeG137RCXyEpK CY9edoHyp9LlYCA8wv4zfji40eg5GJlfj5X6myzL1HvriFRZwJ721Zsbsd/SObeKCKysnB XebroHvwxNs6qoPBEGX+k9dZ77UqARnQF7nivc900LMbw6JUygjjSZN5cKyyhQ== 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=1712841904; 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=VhOfHe/mFdBp0gxT+q2Vugw7yILHoAKKUsV0JX48a6I=; b=JOl0BMSjdUxJhN4aO9IUUiVmhvpfm1c1w+02zGxa90XhaNGnKppcZ0bvRusysSxU/frTzC PG7QeOP60LgAmgOU1UJnm+sMTa5kgxeFufHC/5SVUPE51XExm+1AZs1VAgBsBPBcagSZ1N 06wFw3ZtWB8cLlDo52eZMHInL92JdGyDDCmySpi3LlzRUYwaAgnQHoUCNF+/v/UjM67uIM daw5fg0Wy7aQwj2yn1L3ygIePq+7NUq2osEHehnXj3CAmcca8lY1Jd7tSl5XH5DDT98cnT oDZaKK1dw058ghTdBgyIoafcQL6Cq6nLO0BH+Q/lSzZjnSwCs4XRPBLbqp/opQ== 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 4VFgRN57DJz1Mfv; Thu, 11 Apr 2024 13:25:04 +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 43BDP4AZ047072; Thu, 11 Apr 2024 13:25:04 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43BDP4hK047069; Thu, 11 Apr 2024 13:25:04 GMT (envelope-from git) Date: Thu, 11 Apr 2024 13:25:04 GMT Message-Id: <202404111325.43BDP4hK047069@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: cd9fff7b0431 - stable/14 - pam_xdg: Check asprintf return value 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: dev-commits-src-all+owner@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: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: cd9fff7b0431953db2f50d10fb1ba87809bcc6d6 Auto-Submitted: auto-generated The branch stable/14 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=cd9fff7b0431953db2f50d10fb1ba87809bcc6d6 commit cd9fff7b0431953db2f50d10fb1ba87809bcc6d6 Author: Emmanuel Vadot AuthorDate: 2024-02-27 06:41:59 +0000 Commit: Emmanuel Vadot CommitDate: 2024-04-11 13:24:49 +0000 pam_xdg: Check asprintf return value Reported by: Shawn Webb Sponsored by: Beckhoff Automation GmbH & Co. KG Fixes: 6e69612d5df1 ("pam: Add pam_xdg module") (cherry picked from commit 2d2950c889335b24af7a92f3aaf9946de47bb0bc) --- lib/libpam/modules/pam_xdg/pam_xdg.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/libpam/modules/pam_xdg/pam_xdg.c b/lib/libpam/modules/pam_xdg/pam_xdg.c index d218bc0425f2..d8ba6899da2f 100644 --- a/lib/libpam/modules/pam_xdg/pam_xdg.c +++ b/lib/libpam/modules/pam_xdg/pam_xdg.c @@ -130,7 +130,12 @@ _pam_xdg_open(pam_handle_t *pamh, int flags __unused, } /* Setup the environment variable */ - asprintf(&runtime_dir, "XDG_RUNTIME_DIR=%s/%s", RUNTIME_DIR_PREFIX, user); + rv = asprintf(&runtime_dir, "XDG_RUNTIME_DIR=%s/%s", RUNTIME_DIR_PREFIX, user); + if (rv < 0) { + PAM_VERBOSE_ERROR("asprintf failed %d\n", rv); + rv = PAM_SESSION_ERR; + goto out; + } rv = pam_putenv(pamh, runtime_dir); if (rv != PAM_SUCCESS) { PAM_VERBOSE_ERROR("pam_putenv: failed (%d)", rv); @@ -140,7 +145,12 @@ _pam_xdg_open(pam_handle_t *pamh, int flags __unused, /* Setup the session count file */ for (i = 0; i < XDG_MAX_SESSION; i++) { - asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i); + rv = asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i); + if (rv < 0) { + PAM_VERBOSE_ERROR("asprintf failed %d\n", rv); + rv = PAM_SESSION_ERR; + goto out; + } session_file = openat(rt_dir_prefix, xdg_session_file, O_CREAT | O_EXCL, RUNTIME_DIR_MODE); free(xdg_session_file); if (session_file >= 0) @@ -256,7 +266,12 @@ _pam_xdg_close(pam_handle_t *pamh __unused, int flags __unused, /* Get the last session file created */ for (i = XDG_MAX_SESSION; i >= 0; i--) { - asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i); + rv = asprintf(&xdg_session_file, "%s/xdg_session.%d", user, i); + if (rv < 0) { + PAM_VERBOSE_ERROR("asprintf failed %d\n", rv); + rv = PAM_SESSION_ERR; + goto out; + } session_file = openat(rt_dir_prefix, xdg_session_file, 0); if (session_file >= 0) { unlinkat(rt_dir_prefix, xdg_session_file, 0);