]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix leak on error in kadm5 randkey handling
authorGreg Hudson <ghudson@mit.edu>
Thu, 25 Oct 2018 15:56:58 +0000 (11:56 -0400)
committerGreg Hudson <ghudson@mit.edu>
Fri, 26 Oct 2018 14:23:39 +0000 (10:23 -0400)
An attempt to change the kadmin/history key with the -keepold flag
would leak the KDB entry and keysalt tuple as it returned an error.
Use the cleanup handler instead of returning directly.  Reported by
Bean Zhang.

ticket: 8759
tags: pullup
target_version: 1.16-next
target_version: 1.15-next

src/lib/kadm5/srv/svr_principal.c

index a59a65e8f6818fafed3643b70b2f96d9f44c372d..21c53ece1514c4970b0fc2bb817d837a8a1382c1 100644 (file)
@@ -1564,8 +1564,10 @@ kadm5_randkey_principal_3(void *server_handle,
     if (krb5_principal_compare(handle->context, principal, hist_princ)) {
         /* If changing the history entry, the new entry must have exactly one
          * key. */
-        if (keepold)
-            return KADM5_PROTECT_PRINCIPAL;
+        if (keepold) {
+            ret = KADM5_PROTECT_PRINCIPAL;
+            goto done;
+        }
         new_n_ks_tuple = 1;
     }