From 8cdc021dbb86b76a37e79e636248c5020eb8ab1d Mon Sep 17 00:00:00 2001 From: Ken Raeburn Date: Tue, 3 Feb 2009 16:38:34 +0000 Subject: [PATCH] prefer structure assignment to memcpy git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@21876 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/krlogin.c | 3 +-- src/kadmin/ktutil/ktutil_funcs.c | 2 +- src/lib/crypto/arcfour/arcfour.c | 12 ++++++------ src/lib/gssapi/mechglue/g_initialize.c | 2 +- src/lib/kadm5/srv/svr_principal.c | 2 +- src/lib/krb5/krb/serialize.c | 2 +- 6 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 98b61ac2b..0272b44aa 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -1663,8 +1663,7 @@ int f; ** copy the initial modes we saved into sb; this is ** for restoring to the initial state */ - (void)memcpy(&sb, &defmodes, sizeof(defmodes)); - + sb = defmodes; #else sb.sg_flags &= ~(CBREAK|RAW|TBDELAY); sb.sg_flags |= defflags|tabflag; diff --git a/src/kadmin/ktutil/ktutil_funcs.c b/src/kadmin/ktutil/ktutil_funcs.c index 6fa2a3025..e3e9204d9 100644 --- a/src/kadmin/ktutil/ktutil_funcs.c +++ b/src/kadmin/ktutil/ktutil_funcs.c @@ -172,7 +172,7 @@ krb5_error_code ktutil_add(context, list, princ_str, kvno, goto cleanup; memset(password.data, 0, password.length); password.length = 0; - memcpy(&lp->entry->key, &key, sizeof(krb5_keyblock)); + lp->entry->key = key; } else { printf("Key for %s (hex): ", princ_str); fgets(buf, BUFSIZ, stdin); diff --git a/src/lib/crypto/arcfour/arcfour.c b/src/lib/crypto/arcfour/arcfour.c index 085c997ed..ea3129688 100644 --- a/src/lib/crypto/arcfour/arcfour.c +++ b/src/lib/crypto/arcfour/arcfour.c @@ -81,7 +81,7 @@ krb5_arcfour_encrypt(const struct krb5_enc_provider *enc, d1.data=malloc(d1.length); if (d1.data == NULL) return (ENOMEM); - memcpy(&k1, key, sizeof (krb5_keyblock)); + k1 = *key; k1.length=d1.length; k1.contents= (void *) d1.data; @@ -91,7 +91,7 @@ krb5_arcfour_encrypt(const struct krb5_enc_provider *enc, free(d1.data); return (ENOMEM); } - memcpy(&k2, key, sizeof (krb5_keyblock)); + k2 = *key; k2.length=d2.length; k2.contents=(void *) d2.data; @@ -102,7 +102,7 @@ krb5_arcfour_encrypt(const struct krb5_enc_provider *enc, free(d2.data); return (ENOMEM); } - memcpy(&k3, key, sizeof (krb5_keyblock)); + k3 = *key; k3.length=d3.length; k3.contents= (void *) d3.data; @@ -201,7 +201,7 @@ krb5_arcfour_decrypt(const struct krb5_enc_provider *enc, d1.data=malloc(d1.length); if (d1.data == NULL) return (ENOMEM); - memcpy(&k1, key, sizeof (krb5_keyblock)); + k1 = *key; k1.length=d1.length; k1.contents= (void *) d1.data; @@ -211,7 +211,7 @@ krb5_arcfour_decrypt(const struct krb5_enc_provider *enc, free(d1.data); return (ENOMEM); } - memcpy(&k2, key, sizeof(krb5_keyblock)); + k2 = *key; k2.length=d2.length; k2.contents= (void *) d2.data; @@ -222,7 +222,7 @@ krb5_arcfour_decrypt(const struct krb5_enc_provider *enc, free(d2.data); return (ENOMEM); } - memcpy(&k3, key, sizeof(krb5_keyblock)); + k3 = *key; k3.length=d3.length; k3.contents= (void *) d3.data; diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 1149384a2..85fbe6321 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -638,7 +638,7 @@ gssint_register_mechinfo(gss_mech_info template) releaseMechInfo(&new_cf); return ENOMEM; } - memcpy(new_cf->mech, template->mech, sizeof(struct gss_config)); + *new_cf->mech = *template->mech; if (template->mech_type != NULL) new_cf->mech->mech_type = *(template->mech_type); new_cf->mech_type = &new_cf->mech->mech_type; diff --git a/src/lib/kadm5/srv/svr_principal.c b/src/lib/kadm5/srv/svr_principal.c index c44463bf7..4ee842f4c 100644 --- a/src/lib/kadm5/srv/svr_principal.c +++ b/src/lib/kadm5/srv/svr_principal.c @@ -56,7 +56,7 @@ kadm5_copy_principal(krb5_context context, krb5_const_principal inprinc, krb5_pr return ENOMEM; VALGRIND_CHECK_DEFINED(*inprinc); - memcpy(tempprinc, inprinc, sizeof(krb5_principal_data)); + *tempprinc = *inprinc; nelems = (int) krb5_princ_size(context, inprinc); tempprinc->data = krb5_db_alloc(context, NULL, nelems * sizeof(krb5_data)); diff --git a/src/lib/krb5/krb/serialize.c b/src/lib/krb5/krb/serialize.c index f78bc1618..d1edcf239 100644 --- a/src/lib/krb5/krb/serialize.c +++ b/src/lib/krb5/krb/serialize.c @@ -84,7 +84,7 @@ krb5_register_serializer(krb5_context kcontext, const krb5_ser_entry *entry) kret = ENOMEM; } else - memcpy(stable, entry, sizeof(krb5_ser_entry)); + *stable = *entry; return(kret); } -- 2.26.2