From: Greg Hudson Date: Sun, 12 Mar 2017 16:42:37 +0000 (-0400) Subject: Fix minor memory leaks in kvno X-Git-Tag: krb5-1.16-beta1~133 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=16d3eaf055a2e487ca28fa71e1e57802bc47310d;p=thirdparty%2Fkrb5.git 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 --- diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c index 80bee59e23..df40e390ba 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 6a3fabcb9c..99cccd6b2e 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@KRBTEST.COM\n') realm.run([kadminl, 'getprinc', 'canon'], expected_msg='Principal: canon@KRBTEST.COM\n') -realm.run([kvno, 'alias']) -realm.run([kvno, 'canon']) +realm.run([kvno, 'alias', 'canon']) out = realm.run([klist]) if 'alias@KRBTEST.COM\n' not in out or 'canon@KRBTEST.COM' not in out: fail('After fetching alias and canon, klist is missing one or both')