From: John Kohl Date: Thu, 8 Nov 1990 16:18:57 +0000 (+0000) Subject: change bzero to memset X-Git-Tag: krb5-1.0-alpha3~154 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=c6446557b4d1d2d6b64eab403991fd422574fbe0;p=krb5.git change bzero to memset git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@1438 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/decrypt_tk.c b/src/lib/krb5/krb/decrypt_tk.c index 3c5619bf4..a6903c659 100644 --- a/src/lib/krb5/krb/decrypt_tk.c +++ b/src/lib/krb5/krb/decrypt_tk.c @@ -66,7 +66,8 @@ register krb5_ticket *ticket; free(scratch.data); return retval; } -#define clean_scratch() {bzero(scratch.data, scratch.length); free(scratch.data);} +#define clean_scratch() {memset(scratch.data, 0, scratch.length); \ +free(scratch.data);} if (retval = krb5_finish_key(&eblock)) { clean_scratch(); diff --git a/src/lib/krb5/krb/encode_kdc.c b/src/lib/krb5/krb/encode_kdc.c index 4c7f9f81e..e6abbf87b 100644 --- a/src/lib/krb5/krb/encode_kdc.c +++ b/src/lib/krb5/krb/encode_kdc.c @@ -66,7 +66,8 @@ OLDDECLARG(krb5_data **, enc_rep) return retval; } -#define cleanup_scratch() { (void) bzero(scratch->data, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ +krb5_free_data(scratch); } /* put together an eblock for this encryption */ @@ -80,7 +81,7 @@ OLDDECLARG(krb5_data **, enc_rep) xfree(scratch); return ENOMEM; } - bzero(scratch->data + scratch->length, + memset(scratch->data + scratch->length, 0, dec_rep->enc_part.ciphertext.length - scratch->length); if (!(dec_rep->enc_part.ciphertext.data = malloc(dec_rep->enc_part.ciphertext.length))) { @@ -89,7 +90,7 @@ OLDDECLARG(krb5_data **, enc_rep) } #define cleanup_encpart() { \ -(void) bzero(dec_rep->enc_part.ciphertext.data, \ +(void) memset(dec_rep->enc_part.ciphertext.data, 0, \ dec_rep->enc_part.ciphertext.length); \ free(dec_rep->enc_part.ciphertext.data); \ dec_rep->enc_part.ciphertext.length = 0; \ diff --git a/src/lib/krb5/krb/encrypt_tk.c b/src/lib/krb5/krb/encrypt_tk.c index 0bf772113..74f18e324 100644 --- a/src/lib/krb5/krb/encrypt_tk.c +++ b/src/lib/krb5/krb/encrypt_tk.c @@ -54,7 +54,8 @@ register krb5_ticket *dec_ticket; return retval; } -#define cleanup_scratch() { (void) bzero(scratch->data, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ +krb5_free_data(scratch); } /* put together an eblock for this encryption */ @@ -69,7 +70,7 @@ register krb5_ticket *dec_ticket; xfree(scratch); return ENOMEM; } - bzero(scratch->data + scratch->length, + memset(scratch->data + scratch->length, 0, dec_ticket->enc_part.ciphertext.length - scratch->length); if (!(dec_ticket->enc_part.ciphertext.data = malloc(dec_ticket->enc_part.ciphertext.length))) { @@ -78,7 +79,7 @@ register krb5_ticket *dec_ticket; } #define cleanup_encpart() {\ -(void) bzero(dec_ticket->enc_part.ciphertext.data, \ +(void) memset(dec_ticket->enc_part.ciphertext.data, 0,\ dec_ticket->enc_part.ciphertext.length); \ free(dec_ticket->enc_part.ciphertext.data); \ dec_ticket->enc_part.ciphertext.length = 0; \ diff --git a/src/lib/krb5/krb/gc_frm_kdc.c b/src/lib/krb5/krb/gc_frm_kdc.c index 151432b27..6f8522346 100644 --- a/src/lib/krb5/krb/gc_frm_kdc.c +++ b/src/lib/krb5/krb/gc_frm_kdc.c @@ -84,7 +84,7 @@ krb5_get_cred_from_kdc (ccache, cred, tgts) * XXX we're sharing some substructure here, which is * probably not safe... */ - bzero((char *)&tgtq, sizeof(tgtq)); + memset((char *)&tgtq, 0, sizeof(tgtq)); tgtq.client = cred->client; if (retval = krb5_tgtname(krb5_princ_realm(cred->client), @@ -154,7 +154,7 @@ krb5_get_cred_from_kdc (ccache, cred, tgts) goto out; } /* now get the TGTs */ - bzero((char *)&tgtq, sizeof(tgtq)); + memset((char *)&tgtq, 0, sizeof(tgtq)); tgtq.times = tgt.times; tgtq.client = tgt.client; tgtq.server = *next_server; diff --git a/src/lib/krb5/krb/gc_via_tgt.c b/src/lib/krb5/krb/gc_via_tgt.c index fd02f9821..b05c6fd49 100644 --- a/src/lib/krb5/krb/gc_via_tgt.c +++ b/src/lib/krb5/krb/gc_via_tgt.c @@ -112,7 +112,7 @@ OLDDECLARG(krb5_creds *, cred) return retval; #undef cleanup #define cleanup() {\ - bzero((char *)dec_rep->enc_part2->session->contents,\ + memset((char *)dec_rep->enc_part2->session->contents, 0,\ dec_rep->enc_part2->session->length);\ krb5_free_kdc_rep(dec_rep); } @@ -128,12 +128,12 @@ OLDDECLARG(krb5_creds *, cred) cleanup(); return retval; } - bzero((char *)dec_rep->enc_part2->session->contents, + memset((char *)dec_rep->enc_part2->session->contents, 0, dec_rep->enc_part2->session->length); #undef cleanup #define cleanup() {\ - bzero((char *)cred->keyblock.contents, cred->keyblock.length);\ + memset((char *)cred->keyblock.contents, 0, cred->keyblock.length);\ krb5_free_kdc_rep(dec_rep); } cred->times = dec_rep->enc_part2->times; diff --git a/src/lib/krb5/krb/get_creds.c b/src/lib/krb5/krb/get_creds.c index 4bc264660..74cb00ab6 100644 --- a/src/lib/krb5/krb/get_creds.c +++ b/src/lib/krb5/krb/get_creds.c @@ -45,7 +45,7 @@ krb5_creds *creds; krb5_creds mcreds; krb5_flags fields; - bzero((char *)&mcreds, sizeof(mcreds)); + memset((char *)&mcreds, 0, sizeof(mcreds)); mcreds.server = creds->server; mcreds.client = creds->client; mcreds.times.endtime = creds->times.endtime; diff --git a/src/lib/krb5/krb/get_in_tkt.c b/src/lib/krb5/krb/get_in_tkt.c index ad5a40f5b..fb2772fc5 100644 --- a/src/lib/krb5/krb/get_in_tkt.c +++ b/src/lib/krb5/krb/get_in_tkt.c @@ -154,7 +154,7 @@ OLDDECLARG(krb5_ccache, ccache) } retval = (*decrypt_proc)(decrypt_key, decryptarg, as_reply); - bzero((char *)decrypt_key->contents, decrypt_key->length); + memset((char *)decrypt_key->contents, 0, decrypt_key->length); krb5_free_keyblock(decrypt_key); if (retval) { krb5_free_kdc_rep(as_reply); @@ -182,7 +182,7 @@ OLDDECLARG(krb5_ccache, ccache) (request.till != 0) && (as_reply->enc_part2->times.renew_till > request.till)) ) { - bzero((char *)as_reply->enc_part2->session->contents, + memset((char *)as_reply->enc_part2->session->contents, 0, as_reply->enc_part2->session->length); krb5_free_kdc_rep(as_reply); return KRB5_KDCREP_MODIFIED; @@ -193,12 +193,12 @@ OLDDECLARG(krb5_ccache, ccache) /* fill in the credentials */ if (retval = krb5_copy_keyblock(as_reply->enc_part2->session, &creds->keyblock)) { - bzero((char *)as_reply->enc_part2->session->contents, + memset((char *)as_reply->enc_part2->session->contents, 0, as_reply->enc_part2->session->length); krb5_free_kdc_rep(as_reply); return retval; } -#define cleanup_key() {bzero((char *)creds->keyblock.contents, \ +#define cleanup_key() {memset((char *)creds->keyblock.contents, 0,\ creds->keyblock.length); \ free((char *)creds->keyblock.contents); \ creds->keyblock.contents = 0; \ diff --git a/src/lib/krb5/krb/kdc_rep_dc.c b/src/lib/krb5/krb/kdc_rep_dc.c index 8fb19d724..0ae1cd1c7 100644 --- a/src/lib/krb5/krb/kdc_rep_dc.c +++ b/src/lib/krb5/krb/kdc_rep_dc.c @@ -68,7 +68,8 @@ OLDDECLARG(krb5_kdc_rep *, dec_rep) free(scratch.data); return retval; } -#define clean_scratch() {bzero(scratch.data, scratch.length); free(scratch.data);} +#define clean_scratch() {memset(scratch.data, 0, scratch.length); \ +free(scratch.data);} if (retval = krb5_finish_key(&eblock)) { clean_scratch(); return retval; diff --git a/src/lib/krb5/krb/mk_rep.c b/src/lib/krb5/krb/mk_rep.c index 7df97389a..926da2d05 100644 --- a/src/lib/krb5/krb/mk_rep.c +++ b/src/lib/krb5/krb/mk_rep.c @@ -62,7 +62,8 @@ krb5_data *outbuf; if (retval = encode_krb5_ap_rep_enc_part(repl, &scratch)) return retval; -#define cleanup_scratch() { (void) bzero(scratch->data, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ +krb5_free_data(scratch); } /* put together an eblock for this encryption */ @@ -79,7 +80,7 @@ krb5_data *outbuf; xfree(scratch); return ENOMEM; } - bzero(scratch->data + scratch->length, + memset(scratch->data + scratch->length, 0, reply.enc_part.ciphertext.length - scratch->length); if (!(reply.enc_part.ciphertext.data = malloc(reply.enc_part.ciphertext.length))) { @@ -88,7 +89,7 @@ krb5_data *outbuf; } #define cleanup_encpart() {\ -(void) bzero(reply.enc_part.ciphertext.data, \ +(void) memset(reply.enc_part.ciphertext.data, 0,\ reply.enc_part.ciphertext.length); \ free(reply.enc_part.ciphertext.data); \ reply.enc_part.ciphertext.length = 0; reply.enc_part.ciphertext.data = 0;} diff --git a/src/lib/krb5/krb/mk_req.c b/src/lib/krb5/krb/mk_req.c index d475b462c..c539d6472 100644 --- a/src/lib/krb5/krb/mk_req.c +++ b/src/lib/krb5/krb/mk_req.c @@ -54,11 +54,11 @@ krb5_data *outbuf; /* obtain ticket & session key */ - bzero((char *)&creds, sizeof(creds)); + memset((char *)&creds, 0, sizeof(creds)); creds.server = (krb5_principal) server; if (retval = krb5_cc_get_principal(ccache, &creds.client)) return(retval); - /* creds.times.endtime = 0; -- bzero takes care of this + /* creds.times.endtime = 0; -- memset 0 takes care of this zero means "as long as possible" */ /* creds.keyblock.keytype = 0; -- as well as this. zero means no session keytype diff --git a/src/lib/krb5/krb/mk_req_ext.c b/src/lib/krb5/krb/mk_req_ext.c index 63c191ee8..22972b247 100644 --- a/src/lib/krb5/krb/mk_req_ext.c +++ b/src/lib/krb5/krb/mk_req_ext.c @@ -127,7 +127,8 @@ krb5_data *outbuf; return(retval); } -#define cleanup_scratch() { (void) bzero(scratch->data, scratch->length); krb5_free_data(scratch); } +#define cleanup_scratch() { (void) memset(scratch->data, 0, scratch->length); \ +krb5_free_data(scratch); } /* put together an eblock for this encryption */ @@ -144,7 +145,7 @@ krb5_data *outbuf; retval = ENOMEM; goto clean_ticket; } - bzero(scratch->data + scratch->length, + memset(scratch->data + scratch->length, 0, request.authenticator.ciphertext.length - scratch->length); if (!(request.authenticator.ciphertext.data = malloc(request.authenticator.ciphertext.length))) { @@ -153,7 +154,7 @@ krb5_data *outbuf; } #define cleanup_encpart() {\ -(void) bzero(request.authenticator.ciphertext.data, \ +(void) memset(request.authenticator.ciphertext.data, 0,\ request.authenticator.ciphertext.length); \ free(request.authenticator.ciphertext.data); \ request.authenticator.ciphertext.length = 0; \ diff --git a/src/lib/krb5/krb/mk_safe.c b/src/lib/krb5/krb/mk_safe.c index c4a6699a7..975d0cb8f 100644 --- a/src/lib/krb5/krb/mk_safe.c +++ b/src/lib/krb5/krb/mk_safe.c @@ -87,7 +87,9 @@ OLDDECLARG(krb5_data *, outbuf) if (retval = encode_krb5_safe(&safemsg, &scratch)) return retval; -#define clean_scratch() {(void) bzero((char *)scratch->data, scratch->length); krb5_free_data(scratch);} +#define clean_scratch() {(void) memset((char *)scratch->data, 0,\ + scratch->length); \ + krb5_free_data(scratch);} if (!(safe_checksum.contents = (krb5_octet *) malloc(krb5_cksumarray[sumtype]->checksum_length))) { diff --git a/src/lib/krb5/krb/rd_rep.c b/src/lib/krb5/krb/rd_rep.c index fffe26ff8..419b3439e 100644 --- a/src/lib/krb5/krb/rd_rep.c +++ b/src/lib/krb5/krb/rd_rep.c @@ -83,7 +83,8 @@ krb5_ap_rep_enc_part *repl; (void) krb5_finish_key(&eblock); goto errout; } -#define clean_scratch() {bzero(scratch.data, scratch.length); free(scratch.data);} +#define clean_scratch() {memset(scratch.data, 0, scratch.length); \ +free(scratch.data);} /* finished with the top-level encoding of the ap_rep */ krb5_free_ap_rep(reply); if (retval = krb5_finish_key(&eblock)) { diff --git a/src/lib/krb5/krb/rd_req_dec.c b/src/lib/krb5/krb/rd_req_dec.c index b7b096d09..9592daf0f 100644 --- a/src/lib/krb5/krb/rd_req_dec.c +++ b/src/lib/krb5/krb/rd_req_dec.c @@ -212,7 +212,8 @@ krb5_authenticator **authpp; free(scratch.data); return retval; } -#define clean_scratch() {bzero(scratch.data, scratch.length); free(scratch.data);} +#define clean_scratch() {memset(scratch.data, 0, scratch.length); \ +free(scratch.data);} if (retval = krb5_finish_key(&eblock)) { clean_scratch(); diff --git a/src/lib/krb5/krb/rd_safe.c b/src/lib/krb5/krb/rd_safe.c index af6addeef..cd194e5cc 100644 --- a/src/lib/krb5/krb/rd_safe.c +++ b/src/lib/krb5/krb/rd_safe.c @@ -140,7 +140,7 @@ krb5_data *outbuf; (krb5_pointer) key->contents, key->length, &our_cksum); - (void) bzero((char *)scratch->data, scratch->length); + (void) memset((char *)scratch->data, 0, scratch->length); krb5_free_data(scratch); if (retval) { diff --git a/src/lib/krb5/krb/send_tgs.c b/src/lib/krb5/krb/send_tgs.c index 4e86e26a3..9e8d15983 100644 --- a/src/lib/krb5/krb/send_tgs.c +++ b/src/lib/krb5/krb/send_tgs.c @@ -68,7 +68,7 @@ OLDDECLARG(krb5_response *,rep) krb5_ticket *sec_ticket = 0; krb5_ticket *sec_ticket_arr[2]; - bzero((char *)&tgsreq, sizeof(tgsreq)); + memset((char *)&tgsreq, 0, sizeof(tgsreq)); tgsreq.kdc_options = kdcoptions; tgsreq.server = (krb5_principal) sname; diff --git a/src/lib/krb5/os/read_pwd.c b/src/lib/krb5/os/read_pwd.c index 8d3118de3..d86d6ee1b 100644 --- a/src/lib/krb5/os/read_pwd.c +++ b/src/lib/krb5/os/read_pwd.c @@ -95,10 +95,10 @@ int *size_return; if (setjmp(pwd_jump)) { /* interrupted */ if (readin_string) { - (void) bzero(readin_string, *size_return); + (void) memset(readin_string, 0, *size_return); free(readin_string); } - (void) bzero(return_pwd, *size_return); + (void) memset(return_pwd, 0, *size_return); cleanup(KRB5_LIBOS_PWDINTR); } /* save intrfunc */ @@ -107,12 +107,12 @@ int *size_return; /* put out the prompt */ (void) fputs(prompt,stdout); (void) fflush(stdout); - (void) bzero(return_pwd, *size_return); + (void) memset(return_pwd, 0, *size_return); if (fgets(return_pwd, *size_return, stdin) == NULL) { /* error */ (void) putchar('\n'); - (void) bzero(return_pwd, *size_return); + (void) memset(return_pwd, 0, *size_return); cleanup(KRB5_LIBOS_CANTREADPWD); } (void) putchar('\n'); @@ -132,15 +132,15 @@ int *size_return; (void) fflush(stdout); readin_string = malloc(*size_return); if (!readin_string) { - (void) bzero(return_pwd, *size_return); + (void) memset(return_pwd, 0, *size_return); cleanup(ENOMEM); } - (void) bzero(readin_string, *size_return); + (void) memset(readin_string, 0, *size_return); if (fgets(readin_string, *size_return, stdin) == NULL) { /* error */ (void) putchar('\n'); - (void) bzero(readin_string, *size_return); - (void) bzero(return_pwd, *size_return); + (void) memset(readin_string, 0, *size_return); + (void) memset(return_pwd, 0, *size_return); free(readin_string); cleanup(KRB5_LIBOS_CANTREADPWD); } @@ -155,12 +155,12 @@ int *size_return; /* compare */ if (strncmp(return_pwd, readin_string, *size_return)) { - (void) bzero(readin_string, *size_return); - (void) bzero(return_pwd, *size_return); + (void) memset(readin_string, 0, *size_return); + (void) memset(return_pwd, 0, *size_return); free(readin_string); cleanup(KRB5_LIBOS_BADPWDMATCH); } - (void) bzero(readin_string, *size_return); + (void) memset(readin_string, 0, *size_return); free(readin_string); }