If USE_VALGRIND, check that source principal is defined before copying.
authorKen Raeburn <raeburn@mit.edu>
Thu, 22 Jan 2009 06:34:14 +0000 (06:34 +0000)
committerKen Raeburn <raeburn@mit.edu>
Thu, 22 Jan 2009 06:34:14 +0000 (06:34 +0000)
Initialize magic number fields of allocated name components.

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

src/lib/kadm5/srv/svr_principal.c

index de11acd7ef6b549b42bda2f44bc30ed7a5358b0f..2bdc1f5b29e1997898772ff42bf2fe7b4916562f 100644 (file)
@@ -24,6 +24,12 @@ static char *rcsid = "$Header$";
 
 #endif
 
+#ifdef USE_VALGRIND
+#include <valgrind/memcheck.h>
+#else
+#define VALGRIND_CHECK_DEFINED(LVALUE) ((void)0)
+#endif
+
 extern krb5_principal      master_princ;
 extern krb5_principal      hist_princ;
 extern krb5_keyblock       master_keyblock;
@@ -47,6 +53,7 @@ kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pr
     if (tempprinc == 0)
         return ENOMEM;
 
+    VALGRIND_CHECK_DEFINED(*inprinc);
     memcpy(tempprinc, inprinc, sizeof(krb5_principal_data));
 
     nelems = (int) krb5_princ_size(context, inprinc);
@@ -70,6 +77,7 @@ kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pr
         if (len)
             memcpy(krb5_princ_component(context, tempprinc, i)->data,
                    krb5_princ_component(context, inprinc, i)->data, len);
+       krb5_princ_component(context, tempprinc, i)->magic = KV5M_DATA;
     }
 
     tempprinc->realm.data =