krb5 commit: Fix more password_policy cleanup code

Greg Hudson ghudson at MIT.EDU
Fri Mar 29 11:41:34 EDT 2013


https://github.com/krb5/krb5/commit/43bfc7043301f4d0a9b7ab72f53899685704305d
commit 43bfc7043301f4d0a9b7ab72f53899685704305d
Author: Greg Hudson <ghudson at mit.edu>
Date:   Thu Mar 28 15:57:32 2013 -0400

    Fix more password_policy cleanup code
    
    Initialize policy_dn in krb5_ldap_create_password_policy; free values
    unconditionally in all ldap_pwd_policy.c cleanup handlers.

 src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c
index c6fdbb4..2169aaa 100644
--- a/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c
+++ b/src/plugins/kdb/ldap/libkdb_ldap/ldap_pwd_policy.c
@@ -140,7 +140,7 @@ krb5_ldap_create_password_policy(krb5_context context, osa_policy_ent_t policy)
     kdb5_dal_handle             *dal_handle=NULL;
     krb5_ldap_context           *ldap_context=NULL;
     krb5_ldap_server_handle     *ldap_server_handle=NULL;
-    char                        *strval[2]={NULL}, *policy_dn;
+    char                        *strval[2]={NULL}, *policy_dn=NULL;
 
     /* Clear the global error string */
     krb5_clear_error_message(context);
@@ -175,8 +175,7 @@ krb5_ldap_create_password_policy(krb5_context context, osa_policy_ent_t policy)
     }
 
 cleanup:
-    if (policy_dn != NULL)
-        free (policy_dn);
+    free(policy_dn);
     ldap_mods_free(mods, 1);
     krb5_ldap_put_handle_to_pool(ldap_context, ldap_server_handle);
     return(st);
@@ -353,8 +352,7 @@ krb5_ldap_get_password_policy(krb5_context context, char *name,
                                                policy);
 
 cleanup:
-    if (policy_dn != NULL)
-        free (policy_dn);
+    free(policy_dn);
     return st;
 }
 
@@ -399,8 +397,7 @@ krb5_ldap_delete_password_policy(krb5_context context, char *policy)
 
 cleanup:
     krb5_ldap_put_handle_to_pool(ldap_context, ldap_server_handle);
-    if (policy_dn != NULL)
-        free (policy_dn);
+    free(policy_dn);
 
     return st;
 }
@@ -454,8 +451,7 @@ krb5_ldap_iterate_password_policy(krb5_context context, char *match_expr,
     ldap_msgfree(result);
 
 cleanup:
-    if (entry)
-        free (entry);
+    free(entry);
 
     krb5_ldap_put_handle_to_pool(ldap_context, ldap_server_handle);
     return st;
@@ -467,8 +463,7 @@ krb5_ldap_free_password_policy (context, entry)
     osa_policy_ent_t            entry;
 {
     if (entry) {
-        if (entry->name)
-            free(entry->name);
+        free(entry->name);
         free(entry);
     }
     return;


More information about the cvs-krb5 mailing list