krb5 commit: Fix minor leak in localauth RULE handling

Greg Hudson ghudson at mit.edu
Tue Jun 19 10:51:19 EDT 2018


https://github.com/krb5/krb5/commit/dbc2ccd6d9ff546e2f4af54898c952ffa4eebf44
commit dbc2ccd6d9ff546e2f4af54898c952ffa4eebf44
Author: Greg Hudson <ghudson at mit.edu>
Date:   Fri Jun 15 11:52:22 2018 -0400

    Fix minor leak in localauth RULE handling
    
    In aname_replacer(), initialize current, null it when transferring
    ownership to the caller, and free it on cleanup.  Otherwise it leaks
    on failure.  Reported by Bean Zhang.
    
    ticket: 8698

 src/lib/krb5/os/localauth_rule.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/lib/krb5/os/localauth_rule.c b/src/lib/krb5/os/localauth_rule.c
index 8522108..8be29c4 100644
--- a/src/lib/krb5/os/localauth_rule.c
+++ b/src/lib/krb5/os/localauth_rule.c
@@ -146,7 +146,7 @@ aname_replacer(const char *string, const char **contextp, char **result)
 {
     krb5_error_code ret = 0;
     const char *cp, *ep, *tp;
-    char *current, *newstr, *rule = NULL, *repl = NULL;
+    char *newstr, *rule = NULL, *repl = NULL, *current = NULL;
     krb5_boolean doglobal;
 
     *result = NULL;
@@ -192,8 +192,10 @@ aname_replacer(const char *string, const char **contextp, char **result)
         current = newstr;
     }
     *result = current;
+    current = NULL;
 
 cleanup:
+    free(current);
     free(repl);
     free(rule);
     return ret;


More information about the cvs-krb5 mailing list