krb5 commit: Fix minor leak in localauth RULE handling

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/dbc2ccd6d9ff546e2f4af54898c952ffa4eebf44
commit dbc2ccd6d9ff546e2f4af54898c952ffa4eebf44
Author: Greg Hudson <[email protected]>
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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.