From: John Kohl Date: Wed, 9 May 1990 17:12:11 +0000 (+0000) Subject: changes for new checksum interface X-Git-Tag: krb5-1.0-alpha2~589 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=021d31446fe0c7b5a77527126112a3c36d33cdf4;p=krb5.git changes for new checksum interface git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@816 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/krb/mk_safe.c b/src/lib/krb5/krb/mk_safe.c index 5cd4c4270..405b7b3bd 100644 --- a/src/lib/krb5/krb/mk_safe.c +++ b/src/lib/krb5/krb/mk_safe.c @@ -18,6 +18,7 @@ static char rcsid_mk_safe_c[] = #include #include #include +#include #include #include @@ -94,20 +95,27 @@ OLDDECLARG(krb5_data *, outbuf) #define clean_scratch() {(void) bzero((char *)scratch->data, scratch->length); krb5_free_data(scratch);} + if (!(safe_checksum.contents = (krb5_octet *) + malloc(krb5_cksumarray[sumtype]->checksum_length))) { + clean_scratch(); + return ENOMEM; + } if (retval = (*(krb5_cksumarray[sumtype]->sum_func))(scratch->data, - 0, /* XXX? */ - (krb5_pointer) key->contents, scratch->length, + (krb5_pointer) key->contents, key->length, &safe_checksum)) { + xfree(safe_checksum.contents); clean_scratch(); return retval; } safemsg.checksum = &safe_checksum; clean_scratch(); - if (retval = encode_krb5_safe(&safemsg, &scratch)) + if (retval = encode_krb5_safe(&safemsg, &scratch)) { + xfree(safe_checksum.contents); return retval; - + } + xfree(safe_checksum.contents); *outbuf = *scratch; free((char *)scratch); diff --git a/src/lib/krb5/krb/rd_safe.c b/src/lib/krb5/krb/rd_safe.c index f41648e1d..c03a272c5 100644 --- a/src/lib/krb5/krb/rd_safe.c +++ b/src/lib/krb5/krb/rd_safe.c @@ -18,6 +18,7 @@ static char rcsid_rd_safe_c[] = #include #include #include +#include #include #include @@ -110,12 +111,21 @@ krb5_data *outbuf; cleanup(); return retval; } + message->checksum = his_cksum; + if (!(our_cksum.contents = (krb5_octet *) + malloc(krb5_cksumarray[his_cksum->checksum_type]->checksum_length))) { + cleanup(); + return ENOMEM; + } + +#undef cleanup +#define cleanup() {krb5_free_safe(message); xfree(our_cksum.contents);} + retval = (*(krb5_cksumarray[his_cksum->checksum_type]-> sum_func))(scratch->data, - 0, /* XXX? */ - (krb5_pointer) key->contents, scratch->length, + (krb5_pointer) key->contents, key->length, &our_cksum); (void) bzero((char *)scratch->data, scratch->length); @@ -126,8 +136,6 @@ krb5_data *outbuf; return retval; } -#undef cleanup -#define cleanup() {krb5_free_safe(message); xfree(our_cksum.contents);} if (our_cksum.length != his_cksum->length || bcmp((char *)our_cksum.contents, (char *)his_cksum->contents,