From a2a6b52f9d244c22020808c7ba97ae15a0228ed5 Mon Sep 17 00:00:00 2001 From: Mark Eichin Date: Wed, 15 Jun 1994 22:30:25 +0000 Subject: [PATCH] step 3: bcopy->memcpy or memmove (chose by hand), twiddle args git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@3814 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/telnet/libtelnet/auth.c | 7 +++++-- src/appl/telnet/libtelnet/enc_des.c | 18 +++++++++--------- src/appl/telnet/libtelnet/encrypt.c | 4 ++-- src/appl/telnet/libtelnet/kerberos.c | 6 +++--- src/appl/telnet/libtelnet/krb4encpwd.c | 8 ++++---- src/appl/telnet/libtelnet/read_password.c | 4 ++-- src/appl/telnet/libtelnet/rsaencpwd.c | 12 ++++++------ src/appl/telnet/libtelnet/setenv.c | 2 +- src/appl/telnet/libtelnet/strdup.c | 2 +- 9 files changed, 33 insertions(+), 30 deletions(-) diff --git a/src/appl/telnet/libtelnet/auth.c b/src/appl/telnet/libtelnet/auth.c index fc92b2bf4..142f8ae9e 100644 --- a/src/appl/telnet/libtelnet/auth.c +++ b/src/appl/telnet/libtelnet/auth.c @@ -401,12 +401,15 @@ auth_send(data, cnt) * Save the data, if it is new, so that we can continue looking * at it if the authorization we try doesn't work */ + /* ANSI X3.159-1989 section 3.3.6 indicates that this entire + conditional is undefined. It will probably work on flat address + space UNIX systems though. --eichin@mit.edu */ if (data < _auth_send_data || data > _auth_send_data + sizeof(_auth_send_data)) { auth_send_cnt = cnt > sizeof(_auth_send_data) ? sizeof(_auth_send_data) : cnt; - bcopy((void *)data, (void *)_auth_send_data, auth_send_cnt); + memcpy((void *)_auth_send_data, (void *)data, auth_send_cnt); auth_send_data = _auth_send_data; } else { /* @@ -532,7 +535,7 @@ auth_name(data, cnt) Name, cnt, sizeof(savename)-1); return; } - bcopy((void *)data, (void *)savename, cnt); + memcpy((void *)savename, (void *)data, cnt); savename[cnt] = '\0'; /* Null terminate */ if (auth_debug_mode) printf(">>>%s: Got NAME [%s]\r\n", Name, savename); diff --git a/src/appl/telnet/libtelnet/enc_des.c b/src/appl/telnet/libtelnet/enc_des.c index d3de50578..b3837cb5f 100644 --- a/src/appl/telnet/libtelnet/enc_des.c +++ b/src/appl/telnet/libtelnet/enc_des.c @@ -422,7 +422,7 @@ fb64_session(key, server, fbp) key ? key->type : -1, SK_DES); return; } - bcopy((void *)key->data, (void *)fbp->krbdes_key, sizeof(Block)); + memcpy((void *)fbp->krbdes_key, (void *)key->data, sizeof(Block)); fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_ENCRYPT-1]); fb64_stream_key(fbp->krbdes_key, &fbp->streams[DIR_DECRYPT-1]); @@ -549,8 +549,8 @@ fb64_stream_iv(seed, stp) register struct stinfo *stp; { - bcopy((void *)seed, (void *)stp->str_iv, sizeof(Block)); - bcopy((void *)seed, (void *)stp->str_output, sizeof(Block)); + memcpy((void *)stp->str_iv, (void *)seed, sizeof(Block)); + memcpy((void *)stp->str_output, (void *)seed, sizeof(Block)); des_key_sched(stp->str_ikey, stp->str_sched); @@ -562,10 +562,10 @@ fb64_stream_key(key, stp) Block key; register struct stinfo *stp; { - bcopy((void *)key, (void *)stp->str_ikey, sizeof(Block)); + memcpy((void *)stp->str_ikey, (void *)key, sizeof(Block)); des_key_sched(key, stp->str_sched); - bcopy((void *)stp->str_iv, (void *)stp->str_output, sizeof(Block)); + memcpy((void *)stp->str_output, (void *)stp->str_iv, sizeof(Block)); stp->str_index = sizeof(Block); } @@ -605,7 +605,7 @@ cfb64_encrypt(s, c) if (index == sizeof(Block)) { Block b; des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); + memcpy((void *)stp->str_feed,(void *)b,sizeof(Block)); index = 0; } @@ -639,7 +639,7 @@ cfb64_decrypt(data) if (index == sizeof(Block)) { Block b; des_ecb_encrypt(stp->str_output, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); + memcpy((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ } @@ -681,7 +681,7 @@ ofb64_encrypt(s, c) if (index == sizeof(Block)) { Block b; des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); + memcpy((void *)stp->str_feed,(void *)b,sizeof(Block)); index = 0; } *s++ ^= stp->str_feed[index]; @@ -712,7 +712,7 @@ ofb64_decrypt(data) if (index == sizeof(Block)) { Block b; des_ecb_encrypt(stp->str_feed, b, stp->str_sched, 1); - bcopy((void *)b, (void *)stp->str_feed, sizeof(Block)); + memcpy((void *)stp->str_feed, (void *)b, sizeof(Block)); stp->str_index = 1; /* Next time will be 1 */ index = 0; /* But now use 0 */ } diff --git a/src/appl/telnet/libtelnet/encrypt.c b/src/appl/telnet/libtelnet/encrypt.c index 8f637b693..73a4ba52b 100644 --- a/src/appl/telnet/libtelnet/encrypt.c +++ b/src/appl/telnet/libtelnet/encrypt.c @@ -768,7 +768,7 @@ encrypt_keyid(kp, keyid, len) * Length or contents are different */ kp->keylen = len; - bcopy(keyid, kp->keyid, len); + memcpy(kp->keyid, keyid, len); if (ep->keyid) (void)(*ep->keyid)(dir, kp->keyid, &kp->keylen); } else { @@ -795,7 +795,7 @@ encrypt_send_keyid(dir, keyid, keylen, saveit) ? ENCRYPT_ENC_KEYID : ENCRYPT_DEC_KEYID; if (saveit) { struct key_info *kp = &ki[(dir == DIR_ENCRYPT) ? 0 : 1]; - bcopy(keyid, kp->keyid, keylen); + memcpy(kp->keyid, keyid, keylen); kp->keylen = keylen; } diff --git a/src/appl/telnet/libtelnet/kerberos.c b/src/appl/telnet/libtelnet/kerberos.c index 267337865..47caa98bc 100644 --- a/src/appl/telnet/libtelnet/kerberos.c +++ b/src/appl/telnet/libtelnet/kerberos.c @@ -279,7 +279,7 @@ kerberos4_is(ap, data, cnt) printf("No local realm\r\n"); return; } - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); + memcpy((void *)auth.dat, (void *)data, auth.length = cnt); if (auth_debug_mode) { printf("Got %d bytes of authentication data\r\n", cnt); printf("CK: %d:", kerberos4_cksum(auth.dat, auth.length)); @@ -296,7 +296,7 @@ kerberos4_is(ap, data, cnt) return; } #ifdef ENCRYPTION - bcopy((void *)adat.session, (void *)session_key, sizeof(Block)); + memcpy((void *)session_key, (void *)adat.session, sizeof(Block)); #endif /* ENCRYPTION */ krb_kntoln(&adat, name); @@ -323,7 +323,7 @@ kerberos4_is(ap, data, cnt) } des_key_sched(session_key, sched); - bcopy((void *)data, (void *)datablock, sizeof(Block)); + memcpy((void *)datablock, (void *)data, sizeof(Block)); /* * Take the received encrypted challenge, and encrypt * it again to get a unique session_key for the diff --git a/src/appl/telnet/libtelnet/krb4encpwd.c b/src/appl/telnet/libtelnet/krb4encpwd.c index dbf25de77..965acbbb0 100644 --- a/src/appl/telnet/libtelnet/krb4encpwd.c +++ b/src/appl/telnet/libtelnet/krb4encpwd.c @@ -214,7 +214,7 @@ krb4encpwd_is(ap, data, cnt) return; switch (*data++) { case KRB4_ENCPWD_AUTH: - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); + memcpy((void *)auth.dat, (void *)data, auth.length = cnt); gethostname(lhostname, sizeof(lhostname)); if ((cp = index(lhostname, '.')) != 0) *cp = '\0'; @@ -234,7 +234,7 @@ krb4encpwd_is(ap, data, cnt) return; } - bcopy((void *)adat.session, (void *)session_key, sizeof(Block)); + memcpy((void *)session_key,(void *)adat.session,sizeof(Block)); Data(ap, KRB4_ENCPWD_ACCEPT, (void *)0, 0); auth_finished(ap, AUTH_USER); break; @@ -244,7 +244,7 @@ krb4encpwd_is(ap, data, cnt) * Take the received random challenge text and save * for future authentication. */ - bcopy((void *)data, (void *)challenge, sizeof(Block)); + memcpy((void *)challenge, (void *)data, sizeof(Block)); break; @@ -310,7 +310,7 @@ krb4encpwd_reply(ap, data, cnt) gethostname(hostname, sizeof(hostname)); realm = krb_realmofhost(hostname); - bcopy((void *)data, (void *)challenge, cnt); + memcpy((void *)challenge, (void *)data, cnt); memset(user_passwd, 0, sizeof(user_passwd)); local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0); UserPassword = user_passwd; diff --git a/src/appl/telnet/libtelnet/read_password.c b/src/appl/telnet/libtelnet/read_password.c index cebaaadcd..ad5a0e0a1 100644 --- a/src/appl/telnet/libtelnet/read_password.c +++ b/src/appl/telnet/libtelnet/read_password.c @@ -86,7 +86,7 @@ local_des_read_pw_string(s,max,prompt,verify) } /* XXX assume jmp_buf is typedef'ed to an array */ - bcopy((char *)old_env, (char *)env, sizeof(env)); + memcpy((char *)env, (char *)old_env, sizeof(env)); if (setjmp(env)) goto lose; @@ -136,7 +136,7 @@ lose: /* pop_signals(); */ - bcopy((char *)env, (char *)old_env, sizeof(env)); + memcpy((char *)old_env, (char *)env, sizeof(env)); if (verify) memset(key_string, 0, sizeof (key_string)); s[max-1] = 0; /* force termination */ diff --git a/src/appl/telnet/libtelnet/rsaencpwd.c b/src/appl/telnet/libtelnet/rsaencpwd.c index 4ec81206e..6364deb00 100644 --- a/src/appl/telnet/libtelnet/rsaencpwd.c +++ b/src/appl/telnet/libtelnet/rsaencpwd.c @@ -210,7 +210,7 @@ rsaencpwd_is(ap, data, cnt) cnt--; switch (*data++) { case RSA_ENCPWD_AUTH: - bcopy((void *)data, (void *)auth.dat, auth.length = cnt); + memcpy((void *)auth.dat, (void *)data, auth.length = cnt); if ((fp=fopen(key_file, "r"))==NULL) { Data(ap, RSA_ENCPWD_REJECT, (void *)"Auth failed", -1); @@ -294,12 +294,12 @@ rsaencpwd_is(ap, data, cnt) ptr +=NumEncodeLengthOctets(chalkey_len); *ptr++ = 0x04; /* OCTET STRING */ *ptr++ = challenge_len; - bcopy(challenge, ptr, challenge_len); + memcpy(ptr, challenge, challenge_len); ptr += challenge_len; *ptr++ = 0x04; /* OCTET STRING */ EncodeLength(ptr, i); ptr += NumEncodeLengthOctets(i); - bcopy(key, ptr, i); + memcpy(ptr, key, i); chalkey_len = 1+NumEncodeLengthOctets(chalkey_len)+chalkey_len; Data(ap, RSA_ENCPWD_CHALLENGEKEY, (void *)chalkey, chalkey_len); } @@ -345,7 +345,7 @@ rsaencpwd_reply(ap, data, cnt) * Verify that the response to the challenge is correct. */ - bcopy((void *)data, (void *)chalkey, cnt); + memcpy((void *)chalkey, (void *)data, cnt); ptr = (char *) &chalkey[0]; ptr += DecodeHeaderLength(chalkey); if (*ptr != 0x04) { @@ -354,7 +354,7 @@ rsaencpwd_reply(ap, data, cnt) *ptr++; challenge_len = DecodeValueLength(ptr); ptr += NumEncodeLengthOctets(challenge_len); - bcopy(ptr, challenge, challenge_len); + memcpy(challenge, ptr, challenge_len); ptr += challenge_len; if (*ptr != 0x04) { return; @@ -362,7 +362,7 @@ rsaencpwd_reply(ap, data, cnt) *ptr++; pubkey_len = DecodeValueLength(ptr); ptr += NumEncodeLengthOctets(pubkey_len); - bcopy(ptr, pubkey, pubkey_len); + memcpy(pubkey, ptr, pubkey_len); memset(user_passwd, 0, sizeof(user_passwd)); local_des_read_pw_string(user_passwd, sizeof(user_passwd)-1, "Password: ", 0); UserPassword = user_passwd; diff --git a/src/appl/telnet/libtelnet/setenv.c b/src/appl/telnet/libtelnet/setenv.c index d4fac03a8..4963f924f 100644 --- a/src/appl/telnet/libtelnet/setenv.c +++ b/src/appl/telnet/libtelnet/setenv.c @@ -90,7 +90,7 @@ setenv(name, value, rewrite) p = (char **)malloc((size_t)(sizeof(char *) * (cnt + 2))); if (!p) return (-1); - bcopy(environ, p, cnt * sizeof(char *)); + memcpy(p, environ, cnt * sizeof(char *)); environ = p; } environ[cnt + 1] = NULL; diff --git a/src/appl/telnet/libtelnet/strdup.c b/src/appl/telnet/libtelnet/strdup.c index 7412e428e..e4d9c945b 100644 --- a/src/appl/telnet/libtelnet/strdup.c +++ b/src/appl/telnet/libtelnet/strdup.c @@ -59,6 +59,6 @@ strdup(str) len = strlen(str) + 1; if (!(copy = malloc((u_int)len))) return (NULL); - bcopy(str, copy, len); + memcpy(copy, str, len); return (copy); } -- 2.26.2