]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3-winbind: Fix memory leak with each cached credential login
authorAndreas Schneider <asn@samba.org>
Wed, 29 Jun 2016 11:38:19 +0000 (13:38 +0200)
committerKarolin Seeger <kseeger@samba.org>
Mon, 4 Jul 2016 07:23:21 +0000 (09:23 +0200)
When we allow offline logon and have a lot of logins, windbind will leak
4k of memory which each log in. On systems with heavy load this can grow
quickly and the OOM killer will kill Winbind.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=11999

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Jun 29 19:03:53 CEST 2016 on sn-devel-144

(cherry picked from commit 826f61960ec74deedc9d556a3b8fe04d9178dcd8)

source3/winbindd/winbindd_cache.c

index 356221708192988fc5443431bde7a9a91a11ea46..ef6dc877a7924811d3372e8ca1b6d37e1ef53686 100644 (file)
@@ -3471,7 +3471,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
        struct winbind_cache *cache = get_cache(domain);
        NTSTATUS status;
        int ret;
-       struct cred_list *cred, *oldest = NULL;
+       struct cred_list *cred, *next, *oldest = NULL;
 
        if (!cache->tdb) {
                return NT_STATUS_INTERNAL_DB_ERROR;
@@ -3540,7 +3540,11 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const
                status = NT_STATUS_UNSUCCESSFUL;
        }
 done:
-       SAFE_FREE(wcache_cred_list);
+       for (cred = wcache_cred_list; cred; cred = next) {
+               next = cred->next;
+               DLIST_REMOVE(wcache_cred_list, cred);
+               SAFE_FREE(cred);
+       }
        SAFE_FREE(oldest);
 
        return status;