From: Stefan Metzmacher Date: Mon, 15 Jul 2024 16:47:24 +0000 (+0200) Subject: s3:auth: let smb_pam_conv() handle resp=NULL X-Git-Tag: tdb-1.4.11~107 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=108724ac34663a234ab0a506a1e5d5e0a106af9c;p=thirdparty%2Fsamba.git s3:auth: let smb_pam_conv() handle resp=NULL pam_matrix calls smb_pam_conv() with resp=NULL in some situation, we should not segfault... BUG: https://bugzilla.samba.org/show_bug.cgi?id=9705 Signed-off-by: Stefan Metzmacher Reviewed-by: Andreas Schneider --- diff --git a/source3/auth/pampass.c b/source3/auth/pampass.c index 3e764f32f7d..0be7f9f9d1f 100644 --- a/source3/auth/pampass.c +++ b/source3/auth/pampass.c @@ -131,7 +131,9 @@ static int smb_pam_conv(int num_msg, struct pam_response *reply = NULL; struct smb_pam_userdata *udp = (struct smb_pam_userdata *)appdata_ptr; - *resp = NULL; + if (resp != NULL) { + *resp = NULL; + } if (num_msg <= 0) return PAM_CONV_ERR; @@ -183,8 +185,13 @@ static int smb_pam_conv(int num_msg, return PAM_CONV_ERR; } } - if (reply) - *resp = reply; + if (reply != NULL) { + if (resp != NULL) { + *resp = reply; + } else { + SAFE_FREE(reply); + } + } return PAM_SUCCESS; }