git: 9fe726012df9 - stable/14 - pam_xdg: pam_get_item can return NULL

From: Emmanuel Vadot <manu_at_FreeBSD.org>
Date: Mon, 03 Jun 2024 07:36:22 UTC
The branch stable/14 has been updated by manu:

URL: https://cgit.FreeBSD.org/src/commit/?id=9fe726012df9a125a40df0b70a2e5c6f6b7bb913

commit 9fe726012df9a125a40df0b70a2e5c6f6b7bb913
Author:     Andre Albsmeier <mail@fbsd2.e4m.org>
AuthorDate: 2024-05-27 06:31:34 +0000
Commit:     Emmanuel Vadot <manu@FreeBSD.org>
CommitDate: 2024-06-03 07:35:41 +0000

    pam_xdg: pam_get_item can return NULL
    
    Fix pam_xdg as pam_get_item can return NULL, this happens when pressing
    control + C in xdm for example.
    
    MFC after:      1 week
    PR:             279268
    
    (cherry picked from commit cca0ce62f367d03ed429bf99e41e6aca8cb7f2ac)
---
 lib/libpam/modules/pam_xdg/pam_xdg.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/libpam/modules/pam_xdg/pam_xdg.c b/lib/libpam/modules/pam_xdg/pam_xdg.c
index 4d586a21566a..2c80f0a0332f 100644
--- a/lib/libpam/modules/pam_xdg/pam_xdg.c
+++ b/lib/libpam/modules/pam_xdg/pam_xdg.c
@@ -67,7 +67,7 @@ _pam_xdg_open(pam_handle_t *pamh, int flags __unused,
 
 	/* Get user info */
 	rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
-	if (rv != PAM_SUCCESS) {
+	if (rv != PAM_SUCCESS || user == NULL) {
 		PAM_VERBOSE_ERROR("Can't get user information");
 		goto out;
 	}
@@ -221,7 +221,7 @@ _pam_xdg_close(pam_handle_t *pamh __unused, int flags __unused,
 
 	/* Get user info */
 	rv = pam_get_item(pamh, PAM_USER, (const void **)&user);
-	if (rv != PAM_SUCCESS) {
+	if (rv != PAM_SUCCESS || user == NULL) {
 		PAM_VERBOSE_ERROR("Can't get user information");
 		goto out;
 	}