Correct argument to kadm5_get_principal is a pointer to a struct - not
authorEzra Peisach <epeisach@mit.edu>
Fri, 20 Nov 2009 20:55:34 +0000 (20:55 +0000)
committerEzra Peisach <epeisach@mit.edu>
Fri, 20 Nov 2009 20:55:34 +0000 (20:55 +0000)
a pointer to a pointer.... Does not really matter as the field is not used -
this test program expects a failer.

Clean up memory leaks by freeing principal and releasing context.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23295 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kadm5/unit-test/handle-test.c

index 9f0e3feaa0b1857a610216d7188219859c37b3ce..a77bc1195e4c03bad2fa1b9d83e6190bcf014389 100644 (file)
@@ -21,7 +21,8 @@ int main(int argc, char *argv[])
     kadm5_server_handle_t handle;
     kadm5_server_handle_rec orig_handle;
     kadm5_policy_ent_rec       pol;
-    kadm5_principal_ent_t      princ;
+    kadm5_principal_ent_t    princ;
+    kadm5_principal_ent_rec  kprinc;
     krb5_keyblock      *key;
     krb5_principal     tprinc;
     krb5_context       context;
@@ -40,7 +41,7 @@ int main(int argc, char *argv[])
     orig_handle = *handle;
     handle->magic_number = KADM5_STRUCT_VERSION;
     krb5_parse_name(context, "testuser", &tprinc);
-    ret = kadm5_get_principal(server_handle, tprinc, &princ,
+    ret = kadm5_get_principal(server_handle, tprinc, &kprinc,
                               KADM5_PRINCIPAL_NORMAL_MASK);
     if(ret != KADM5_BAD_SERVER_HANDLE) {
         fprintf(stderr, "%s -- returned -- %s\n", "get-principal",
@@ -55,6 +56,7 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    princ = &kprinc;
     ret = kadm5_create_principal(server_handle, princ, KADM5_PRINCIPAL, "pass");
     if(ret != KADM5_BAD_SERVER_HANDLE) {
         fprintf(stderr, "%s -- returned -- %s\n", "create-principal",
@@ -132,5 +134,7 @@ int main(int argc, char *argv[])
         exit(1);
     }
 
+    krb5_free_principal(context, tprinc);
+    krb5_free_context(context);
     exit(0);
 }