Unless HAVE_C_STRUCTURE_ASSIGNMENT is defined, use memcpy to copy
authorTheodore Tso <tytso@mit.edu>
Fri, 21 Apr 1995 03:10:41 +0000 (03:10 +0000)
committerTheodore Tso <tytso@mit.edu>
Fri, 21 Apr 1995 03:10:41 +0000 (03:10 +0000)
structures around, instead of using structure assignments.  (Which
aren't guaranteed to work on some broken compilers.)

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

14 files changed:
src/lib/krb5/krb/ChangeLog
src/lib/krb5/krb/copy_addrs.c
src/lib/krb5/krb/copy_athctr.c
src/lib/krb5/krb/copy_auth.c
src/lib/krb5/krb/copy_cksum.c
src/lib/krb5/krb/copy_creds.c
src/lib/krb5/krb/copy_key.c
src/lib/krb5/krb/copy_princ.c
src/lib/krb5/krb/copy_tick.c
src/lib/krb5/krb/gc_2tgt.c
src/lib/krb5/krb/gc_frm_kdc.c
src/lib/krb5/krb/gc_via_tgt.c
src/lib/krb5/krb/get_creds.c
src/lib/krb5/krb/mk_req_ext.c

index cbe035a7721f08d7a2d0a64cfb7338de7859cd5f..55e9f297464a6a949a723350d76984542dea4581 100644 (file)
@@ -1,5 +1,13 @@
 Thu Apr 20 16:23:23 1995  Theodore Y. Ts'o  (tytso@dcl)
 
+       * copy_addrs.c, copy_athctr.c, copy_auth.c, copy_cksum.c,
+       copy_creds.c, copy_key.c, copy_princ.c, copy_tick.c,
+       gc_2tgt.c, gc_frm_kdc.c, gc_via_tgt.c, get_creds.c,
+       mk_req_ext.c: Unless HAVE_C_STRUCTURE_ASSIGNMENT is defined, use
+               memcpy to copy structures around, instead of using
+               structure assignments.  (Which aren't guaranteed to work
+               on some broken compilers.)
+
        * mk_req.c (krb5_mk_req): Use krb5_sname_to_principal() in order
                to create the service principal from the service and
                hostname pair.  This allows for the host cannoncialization
index fa37731032269318cd84ecf6d2f6e949a3eb7ad5..5d17ed3e70d23f0b205462b28d77a46a13b9af13 100644 (file)
@@ -36,7 +36,11 @@ krb5_address **outad;
 
     if (!(tmpad = (krb5_address *)malloc(sizeof(*tmpad))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tmpad = *inad;
+#else
+    memcpy(tmpad, inad, sizeof(krb5_address));
+#endif
     if (!(tmpad->contents = (krb5_octet *)malloc(inad->length))) {
        krb5_xfree(tmpad);
        return ENOMEM;
index 5523f3134c1bc0ad8f938378ae52d6b2ea5652e4..d162fb2152f534138b129f0985631c21c6bfdaa5 100644 (file)
@@ -37,7 +37,11 @@ krb5_authenticator **authto;
 
     if (!(tempto = (krb5_authenticator *)malloc(sizeof(*tempto))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempto = *authfrom;
+#else
+    memcpy(tempto, authfrom, sizeof(krb5_authenticator));
+#endif
 
     retval = krb5_copy_principal(context, authfrom->client, &tempto->client);
     if (retval) {
index 23c91dc28ec0ef4d59dd4f330d589415d1bf689c..759608ca5bec5c00798fbea3ee020b1c3f403278 100644 (file)
@@ -36,7 +36,11 @@ krb5_authdata **outad;
 
     if (!(tmpad = (krb5_authdata *)malloc(sizeof(*tmpad))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tmpad = *inad;
+#else
+    memcpy(tmpad, inad, sizeof(krb5_authdata));
+#endif
     if (!(tmpad->contents = (krb5_octet *)malloc(inad->length))) {
        krb5_xfree(tmpad);
        return ENOMEM;
index 4d8d3efc6d260a0a6e540f64c63ddcd6b428395d..5a9a893d4a8d5ed671aec35781626b658482bc16 100644 (file)
@@ -36,7 +36,11 @@ krb5_copy_checksum(context, ckfrom, ckto)
 
     if (!(tempto = (krb5_checksum *)malloc(sizeof(*tempto))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempto = *ckfrom;
+#else
+    memcpy(tempto, ckfrom, sizeof(krb5_checksum));
+#endif
 
     if (!(tempto->contents =
          (krb5_octet *)malloc(tempto->length))) {
index 1b58af91413d05820295e0e3f4ce1bab444a3920..712ca383314bbf68868353d35c106d091d1637f7 100644 (file)
@@ -43,7 +43,11 @@ krb5_copy_creds(context, incred, outcred)
     if (!(tempcred = (krb5_creds *)malloc(sizeof(*tempcred))))
        return ENOMEM;
 
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempcred = *incred;               /* copy everything quickly */
+#else
+    memcpy(tempcred, incred, sizeof(krb5_creds));
+#endif
     retval = krb5_copy_principal(context, incred->client, &tempcred->client);
     if (retval)
        goto cleanlast;
index 065b66ef828351fd30d9bc569117e31a45847a09..e71f39961a63795fb438692162118ec588593b8c 100644 (file)
@@ -39,7 +39,11 @@ krb5_copy_keyblock(context, from, to)
 
        if (!(new_key = (krb5_keyblock *) malloc(sizeof(krb5_keyblock))))
                return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
        *new_key = *from;
+#else
+       memcpy(new_key, from, sizeof(krb5_keyblock));
+#endif
        if (!(new_key->contents = (krb5_octet *)malloc(new_key->length))) {
                krb5_xfree(new_key);
                return(ENOMEM);
index 43836eb067a9f31c80e03a6473e4c4dff598b53d..4dbf44e7ee5508ce53f72e133699b34d6ae2448b 100644 (file)
@@ -43,7 +43,11 @@ krb5_copy_principal(context, inprinc, outprinc)
     if (tempprinc == 0)
        return ENOMEM;
 
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempprinc = *inprinc;     /* Copy all of the non-allocated pieces */
+#else
+    memcpy(tempprinc, inprinc, sizeof(krb5_principal_data));
+#endif
 
     nelems = (int) krb5_princ_size(context, inprinc);
     tempprinc->data = malloc(nelems * sizeof(krb5_data));
index 3d9b99a995328bc535ee916e03302c4135bc21a5..a4dbed4df8e77577be7d9204c67d71cb18670de0 100644 (file)
@@ -37,7 +37,11 @@ krb5_copy_enc_tkt_part(context, partfrom, partto)
 
     if (!(tempto = (krb5_enc_tkt_part *)malloc(sizeof(*tempto))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempto = *partfrom;
+#else
+    memcpy(tempto, partfrom, sizeof(krb5_enc_tkt_part));
+#endif
     retval = krb5_copy_keyblock(context, partfrom->session,
                                &tempto->session);
     if (retval) {
@@ -103,7 +107,11 @@ krb5_copy_ticket(context, from, pto)
 
     if (!(tempto = (krb5_ticket *)malloc(sizeof(*tempto))))
        return ENOMEM;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *tempto = *from;
+#else
+    memcpy(tempto, from, sizeof(krb5_ticket));
+#endif
     retval = krb5_copy_principal(context, from->server, &tempto->server);
     if (retval) {
        krb5_xfree(tempto);
index 9f9106fc06d66f152d0a3ca2264e56a32be7412a..c5ddcf7c4240b67dfd00bce457a06ef22d8c3eef 100644 (file)
@@ -139,7 +139,13 @@ krb5_get_cred_via_2tgt (context, tgt, kdcoptions, sumtype, in_cred, out_cred)
        goto errout;
 
     /* Should verify that the ticket is what we asked for. */
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     (*out_cred)->times = dec_rep->enc_part2->times;
+#else
+    memcpy(&(*out_cred)->times, &dec_rep->enc_part2->times, 
+          sizeof(krb5_ticket_times));
+#endif
+
     (*out_cred)->ticket_flags = dec_rep->enc_part2->flags;
     (*out_cred)->is_skey = TRUE;
     if (dec_rep->enc_part2->caddrs)
index 30e278d38ca1baf89739929e74d76e28df1897b1..b82d023a17912a947155e3e6b286cc8f04ac74e9 100644 (file)
@@ -241,7 +241,12 @@ krb5_get_cred_from_kdc(context, ccache, in_cred, out_cred, tgts)
     
        krb5_free_cred_contents(context, &tgtq);
        memset(&tgtq, 0, sizeof(tgtq));
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
        tgtq.times        = tgt.times;
+#else
+       memcpy(&tgtq.times, &tgt.times, sizeof(krb5_ticket_times));
+#endif
+
        if (retval = krb5_copy_principal(context, tgt.client, &tgtq.client))
            goto cleanup;
        if(retval = krb5_copy_principal(context, int_server, &tgtq.server))
index c0d31c25d0b660a6cd013d03ae9e1cf21f5c7fcf..5c15a013806a948bf343c3b4026cb0801414db44 100644 (file)
@@ -137,7 +137,12 @@ krb5_get_cred_via_tgt (context, tgt, kdcoptions, sumtype, in_cred, out_cred)
     }
 
     (*out_cred)->keyblock.etype = dec_rep->ticket->enc_part.etype;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     (*out_cred)->times = dec_rep->enc_part2->times;
+#else
+    memcpy(&(*out_cred)->times, &dec_rep->enc_part2->times, 
+          sizeof(krb5_ticket_times));
+#endif
 
 #if 0
     /* XXX probably need access to the request */
index bc9360a9370328dc305691deb6d9ee503e220650..58ecd003512d35ca8501e735f9c2cca862bea48b 100644 (file)
@@ -61,7 +61,11 @@ krb5_get_credentials(context, options, ccache, in_creds, out_creds)
 
     memset((char *)&mcreds, 0, sizeof(krb5_creds));
     mcreds.times.endtime = in_creds->times.endtime;
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     mcreds.keyblock = in_creds->keyblock;
+#else
+    memcpy(&mcreds.keyblock, &in_creds->keyblock, sizeof(krb5_keyblock));
+#endif
     mcreds.authdata = in_creds->authdata;
     mcreds.server = in_creds->server;
     mcreds.client = in_creds->client;
index f146d14832c949c30a3743a0bf79e4bde7f0996d..6cfaf11b30425889f34f4d5ebcde7e374d309f68 100644 (file)
@@ -221,7 +221,12 @@ krb5_mk_req_extended(context, auth_context, ap_req_options, in_data, in_creds,
     if (retval = encode_krb5_ap_req(&request, &toutbuf))
        goto cleanup_cksum;
     
+#ifdef HAVE_C_STRUCTURE_ASSIGNMENT
     *outbuf = *toutbuf;
+#else
+    memcpy(outbuf, toutbuf, sizeof(krb5_data));
+#endif
+
     krb5_xfree(toutbuf);
 
 cleanup_cksum: