krb5 commit: Fix minor memory leaks in kvno

Greg Hudson ghudson at mit.edu
Mon Mar 13 13:01:38 EDT 2017


https://github.com/krb5/krb5/commit/16d3eaf055a2e487ca28fa71e1e57802bc47310d
commit 16d3eaf055a2e487ca28fa71e1e57802bc47310d
Author: Greg Hudson <ghudson at mit.edu>
Date:   Sun Mar 12 12:42:37 2017 -0400

    Fix minor memory leaks in kvno
    
    In do_k5_kvno(), free allocated values on success as well as failure.
    In t_kdb.py, run kvno with multiple arguments to manifest this leak in
    asan and valgrind.  Reported by Cel Skeggs.
    
    ticket: 8558

 src/clients/kvno/kvno.c |    8 +++++---
 src/tests/t_kdb.py      |    3 +--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c
index 80bee59..df40e39 100644
--- a/src/clients/kvno/kvno.c
+++ b/src/clients/kvno/kvno.c
@@ -326,9 +326,7 @@ static void do_v5_kvno (int count, char *names[],
                 printf(_("%s: kvno = %d\n"), princ, ticket->enc_part.kvno);
         }
 
-        continue;
-
-    error:
+    cleanup:
         if (server != NULL)
             krb5_free_principal(context, server);
         if (ticket != NULL)
@@ -337,7 +335,11 @@ static void do_v5_kvno (int count, char *names[],
             krb5_free_creds(context, out_creds);
         if (princ != NULL)
             krb5_free_unparsed_name(context, princ);
+        continue;
+
+    error:
         errors++;
+        goto cleanup;
     }
 
     if (keytab)
diff --git a/src/tests/t_kdb.py b/src/tests/t_kdb.py
index 6a3fabc..99cccd6 100755
--- a/src/tests/t_kdb.py
+++ b/src/tests/t_kdb.py
@@ -328,8 +328,7 @@ realm.run([kadminl, 'getprinc', 'alias'],
           expected_msg='Principal: canon at KRBTEST.COM\n')
 realm.run([kadminl, 'getprinc', 'canon'],
           expected_msg='Principal: canon at KRBTEST.COM\n')
-realm.run([kvno, 'alias'])
-realm.run([kvno, 'canon'])
+realm.run([kvno, 'alias', 'canon'])
 out = realm.run([klist])
 if 'alias at KRBTEST.COM\n' not in out or 'canon at KRBTEST.COM' not in out:
     fail('After fetching alias and canon, klist is missing one or both')


More information about the cvs-krb5 mailing list