]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix minor leak in localauth RULE handling 795/head
authorGreg Hudson <ghudson@mit.edu>
Fri, 15 Jun 2018 15:52:22 +0000 (11:52 -0400)
committerGreg Hudson <ghudson@mit.edu>
Tue, 19 Jun 2018 14:38:29 +0000 (10:38 -0400)
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

index 852210825deec9ded4197d5338829c86ac846243..8be29c415d49924438bf84506842d0531f0cf60d 100644 (file)
@@ -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;