changes for new checksum interface
authorJohn Kohl <jtkohl@mit.edu>
Wed, 9 May 1990 17:12:11 +0000 (17:12 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Wed, 9 May 1990 17:12:11 +0000 (17:12 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@816 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/mk_safe.c
src/lib/krb5/krb/rd_safe.c

index 5cd4c42707e412df70fc988ca5f0d2bbe607ade1..405b7b3bd9049dd1f700cbb618548b9c3663d41f 100644 (file)
@@ -18,6 +18,7 @@ static char rcsid_mk_safe_c[] =
 #include <krb5/copyright.h>
 #include <krb5/krb5.h>
 #include <krb5/krb5_err.h>
+#include <errno.h>
 
 #include <krb5/asn1.h>
 #include <stdio.h>
@@ -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);
 
index f41648e1d0c75dc33a371cd371109c2b67bfdea9..c03a272c5696c67e97a8cac814ff74b3733748f6 100644 (file)
@@ -18,6 +18,7 @@ static char rcsid_rd_safe_c[] =
 #include <krb5/copyright.h>
 #include <krb5/krb5.h>
 #include <krb5/krb5_err.h>
+#include <errno.h>
 
 #include <krb5/asn1.h>
 #include <stdio.h>
@@ -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,