krb5 commit: Fix minor memory leaks in kvno

Greg Hudson <[email protected]>
Newsgroups gmane.comp.encryption.kerberos.cvs
Message-ID <[email protected]>
https://github.com/krb5/krb5/commit/16d3eaf055a2e487ca28fa71e1e57802bc47310d
commit 16d3eaf055a2e487ca28fa71e1e57802bc47310d
Author: Greg Hudson <[email protected]>
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: [email protected]\n')
 realm.run([kadminl, 'getprinc', 'canon'],
           expected_msg='Principal: [email protected]\n')
-realm.run([kvno, 'alias'])
-realm.run([kvno, 'canon'])
+realm.run([kvno, 'alias', 'canon'])
 out = realm.run([klist])
 if '[email protected]\n' not in out or '[email protected]' not in out:
     fail('After fetching alias and canon, klist is missing one or both')
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.