]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:auth: let smb_pam_conv() handle resp=NULL
authorStefan Metzmacher <metze@samba.org>
Mon, 15 Jul 2024 16:47:24 +0000 (18:47 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 17 Jul 2024 10:12:36 +0000 (10:12 +0000)
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 <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
source3/auth/pampass.c

index 3e764f32f7d3d3bad2397723e04e8bf76e32e845..0be7f9f9d1fb3d50f5d17c3c7425877b5091a407 100644 (file)
@@ -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;
 }