lists.arthurdejong.org
RSS feed

nss-pam-ldapd branch master updated. 0.9.2-16-g8e74848

[Date Prev][Date Next] [Thread Prev][Thread Next]

nss-pam-ldapd branch master updated. 0.9.2-16-g8e74848



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "nss-pam-ldapd".

The branch, master has been updated
       via  8e74848cff12ea9902c59081515d46fc51d6f545 (commit)
      from  328894237b24e50b8d39f1fe85f9fa7e2d37e5de (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://arthurdejong.org/git/nss-pam-ldapd/commit/?id=8e74848cff12ea9902c59081515d46fc51d6f545

commit 8e74848cff12ea9902c59081515d46fc51d6f545
Author: Arthur de Jong <arthur@arthurdejong.org>
Date:   Sun Jan 5 14:47:30 2014 +0100

    Fix memory leaks related to set_pop()
    
    Some pieces of code did not properly free() the value returned by
    set_pop().
    
    The leak in group code was related to the introduction of nested group
    functionality in 41ba574 (merged in 3daa68d) so should only be present
    in releases 0.9.0 forward.
    
    The leak in the netgroup code only ended up in the Solaris version of
    the NSS module and was introduced in 4ea9ad1 (merged in 5c8779d). This
    leak is present in all releases from 0.8.0 forward.

diff --git a/nslcd/group.c b/nslcd/group.c
index fabc1e6..725b196 100644
--- a/nslcd/group.c
+++ b/nslcd/group.c
@@ -5,7 +5,7 @@
 
    Copyright (C) 1997-2006 Luke Howard
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Arthur de Jong
+   Copyright (C) 2006-2014 Arthur de Jong
    Copyright (C) 2013 Steve Hill
 
    This library is free software; you can redistribute it and/or
@@ -337,6 +337,7 @@ static int write_group(TFILE *fp, MYLDAP_ENTRY *entry, 
const char *reqname,
           if (search != NULL)
             while ((entry2 = myldap_get_entry(search, NULL)) != NULL)
               getmembers(entry2, session, set, seen, subgroups);
+          free(tmp);
         }
       }
       members = set_tolist(set);
@@ -483,10 +484,12 @@ int nslcd_group_bymember(TFILE *fp, MYLDAP_SESSION 
*session)
       if (mkfilter_group_bymemberdn(dn, filter, sizeof(filter)))
       {
         log_log(LOG_WARNING, "nslcd_group_bymember(): filter buffer too 
small");
+        free((void *)dn);
         set_free(seen);
         set_free(tocheck);
         return -1;
       }
+      free((void *)dn);
       /* do the LDAP searches */
       for (i = 0; (base = group_bases[i]) != NULL; i++)
       {
@@ -495,7 +498,8 @@ int nslcd_group_bymember(TFILE *fp, MYLDAP_SESSION *session)
         {
           while ((entry = myldap_get_entry(search, NULL)) != NULL)
           {
-            if (!set_contains(seen, dn = myldap_get_dn(entry)))
+            dn = myldap_get_dn(entry);
+            if (!set_contains(seen, dn))
             {
               set_add(seen, dn);
               set_add(tocheck, dn);
diff --git a/nss/netgroup.c b/nss/netgroup.c
index bd70768..81eb33d 100644
--- a/nss/netgroup.c
+++ b/nss/netgroup.c
@@ -2,7 +2,7 @@
    netgroup.c - NSS lookup functions for netgroup entries
 
    Copyright (C) 2006 West Consulting
-   Copyright (C) 2006, 2007, 2008, 2010, 2012, 2013 Arthur de Jong
+   Copyright (C) 2006-2014 Arthur de Jong
    Copyright (C) 2010 Symas Corporation
 
    This library is free software; you can redistribute it and/or
@@ -178,7 +178,8 @@ struct setnetgrent_backend {
 #define SETNETGRENT_ARGS(args) ((struct nss_setnetgrent_args *)(args))
 #define GETNETGRENT_ARGS(args) ((struct nss_getnetgrent_args *)(args))
 
-/* return a netgroup that has not been traversed */
+/* return a netgroup that has not been traversed (the caller should use
+   free() to free it) */
 static char *find_unseen_netgroup(struct setnetgrent_backend *be)
 {
   char *group;
@@ -189,6 +190,7 @@ static char *find_unseen_netgroup(struct 
setnetgrent_backend *be)
       return NULL;
     if (!set_contains(be->seen_groups, group))
       return group;
+    free(group);
   }
 }
 
diff --git a/tests/test_set.c b/tests/test_set.c
index d2525be..c68e9c9 100644
--- a/tests/test_set.c
+++ b/tests/test_set.c
@@ -2,7 +2,7 @@
    test_set.c - simple test for the set module
    This file is part of the nss-pam-ldapd library.
 
-   Copyright (C) 2008, 2009, 2010, 2012 Arthur de Jong
+   Copyright (C) 2008-2014 Arthur de Jong
 
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -43,6 +43,7 @@ int main(int UNUSED(argc), char UNUSED(*argv[]))
   SET *set;
   const char **list;
   int i;
+  const char *v;
 
   /* initialize */
   set = set_new();
@@ -68,9 +69,12 @@ int main(int UNUSED(argc), char UNUSED(*argv[]))
   }
 
   /* remove keys from the set */
-  assert(isknownvalue(set_pop(set)));
-  assert(isknownvalue(set_pop(set)));
-  assert(isknownvalue(set_pop(set)));
+  assert(isknownvalue(v = set_pop(set)));
+  free((void *)v);
+  assert(isknownvalue(v = set_pop(set)));
+  free((void *)v);
+  assert(isknownvalue(v = set_pop(set)));
+  free((void *)v);
   assert(set_pop(set) == NULL);
 
   /* free set */

-----------------------------------------------------------------------

Summary of changes:
 nslcd/group.c    |    8 ++++++--
 nss/netgroup.c   |    6 ++++--
 tests/test_set.c |   12 ++++++++----
 3 files changed, 18 insertions(+), 8 deletions(-)


hooks/post-receive
-- 
nss-pam-ldapd
-- 
To unsubscribe send an email to
nss-pam-ldapd-commits-unsubscribe@lists.arthurdejong.org or see
http://lists.arthurdejong.org/nss-pam-ldapd-commits/