s3: Fix crash in pam_winbind, another reference to freed memory.
authorBo Yang <boyang@samba.org>
Sat, 24 Oct 2009 01:20:00 +0000 (09:20 +0800)
committerKarolin Seeger <kseeger@samba.org>
Mon, 26 Oct 2009 07:56:44 +0000 (08:56 +0100)
Fix bug #6840.

Signed-off-by: Bo Yang <boyang@samba.org>
(cherry picked from commit b9a3f1dd85d168c15df846dba525f4f882d1acf8)

nsswitch/pam_winbind.c

index ab22c7cbb57c3ad0dc042b2e581fdc376871ed0a..ec05f7569759bfe55ca9542fd323acdeb4c22d33 100644 (file)
@@ -1784,7 +1784,7 @@ static int winbind_auth_request(struct pwb_context *ctx,
        if (logon.blobs) {
                wbcFreeMemory(logon.blobs);
        }
-       if (info && info->blobs) {
+       if (info && info->blobs && !p_info) {
                wbcFreeMemory(info->blobs);
        }
        if (error && !p_error) {
@@ -3138,10 +3138,14 @@ int pam_sm_chauthtok(pam_handle_t * pamh, int flags,
                                        free(username_ret);
                                }
 
-                               wbcFreeMemory(info);
-                               wbcFreeMemory(policy);
                        }
 
+                       if (info && info->blobs) {
+                               wbcFreeMemory(info->blobs);
+                       }
+                       wbcFreeMemory(info);
+                       wbcFreeMemory(policy);
+
                        goto out;
                }
        } else {