add padding area, and zero it (for encryption functions)
authorJohn Kohl <jtkohl@mit.edu>
Fri, 18 May 1990 10:47:32 +0000 (10:47 +0000)
committerJohn Kohl <jtkohl@mit.edu>
Fri, 18 May 1990 10:47:32 +0000 (10:47 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@885 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/krb5/krb/encode_kdc.c
src/lib/krb5/krb/encrypt_tk.c
src/lib/krb5/krb/mk_priv.c
src/lib/krb5/krb/mk_req_ext.c

index 89cd913b2a52d4b8c51bbce8b38e59abb8b117c8..3d4df54038d93998b3db258a5490cff72abf4688 100644 (file)
@@ -74,7 +74,15 @@ OLDDECLARG(krb5_data **, enc_rep)
 
     eblock.crypto_entry = krb5_csarray[dec_rep->etype]->system;
     dec_rep->enc_part.length = krb5_encrypt_size(scratch->length,
-                                             eblock.crypto_entry);
+                                                eblock.crypto_entry);
+    /* add padding area, and zero it */
+    if (!(scratch->data = realloc(scratch->data, dec_rep->enc_part.length))) {
+       /* may destroy scratch->data */
+       xfree(scratch);
+       return ENOMEM;
+    }
+    bzero(scratch->data + scratch->length,
+         dec_rep->enc_part.length - scratch->length);
     if (!(dec_rep->enc_part.data = malloc(dec_rep->enc_part.length))) {
        retval = ENOMEM;
        goto clean_scratch;
index 813afe810b3af97574aba1761a8d55e0a379e1ba..f1aafbcde0d3beb1a0cb75be55d8477bf6426011 100644 (file)
@@ -61,7 +61,15 @@ register krb5_ticket *dec_ticket;
 
     eblock.crypto_entry = krb5_csarray[dec_ticket->etype]->system;
     dec_ticket->enc_part.length = krb5_encrypt_size(scratch->length,
-                                                    eblock.crypto_entry);
+                                                   eblock.crypto_entry);
+    /* add padding area, and zero it */
+    if (!(scratch->data = realloc(scratch->data, dec_ticket->enc_part.length))) {
+       /* may destroy scratch->data */
+       xfree(scratch);
+       return ENOMEM;
+    }
+    bzero(scratch->data + scratch->length,
+         dec_ticket->enc_part.length - scratch->length);
     if (!(dec_ticket->enc_part.data = malloc(dec_ticket->enc_part.length))) {
        retval = ENOMEM;
        goto clean_scratch;
index c6359d4bf5aeb8e73c72bad7e1eca9f26d4b2139..c46648b77aabd434c2204cb36ce6c0321b7fc6a0 100644 (file)
@@ -90,7 +90,15 @@ OLDDECLARG(krb5_data *, outbuf)
 
     eblock.crypto_entry = krb5_csarray[etype]->system;
     privmsg.enc_part.length = krb5_encrypt_size(scratch->length,
-                                                     eblock.crypto_entry);
+                                               eblock.crypto_entry);
+    /* add padding area, and zero it */
+    if (!(scratch->data = realloc(scratch->data, privmsg.enc_part.length))) {
+       /* may destroy scratch->data */
+       xfree(scratch);
+       return ENOMEM;
+    }
+    bzero(scratch->data + scratch->length,
+         privmsg.enc_part.length - scratch->length);
     if (!(privmsg.enc_part.data = malloc(privmsg.enc_part.length))) {
         retval = ENOMEM;
         goto clean_scratch;
index d65f529146474592112896387f5bdf5d57d3cf5d..f0a124af68e31f515d1847c11e5c668c27649419 100644 (file)
@@ -123,6 +123,15 @@ krb5_data *outbuf;
     eblock.crypto_entry = krb5_csarray[etype]->system;
     request.authenticator.length = krb5_encrypt_size(scratch->length,
                                                     eblock.crypto_entry);
+    /* add padding area, and zero it */
+    if (!(scratch->data = realloc(scratch->data, request.authenticator.length))) {
+       /* may destroy scratch->data */
+       xfree(scratch);
+       retval = ENOMEM;
+       goto clean_ticket;
+    }
+    bzero(scratch->data + scratch->length,
+         request.authenticator.length - scratch->length);
     if (!(request.authenticator.data = malloc(request.authenticator.length))) {
        retval = ENOMEM;
        goto clean_scratch;
@@ -168,6 +177,7 @@ krb5_data *outbuf;
     cleanup_encpart();
  clean_scratch:
     cleanup_scratch();
+ clean_ticket:
     cleanup_ticket();
 
     return retval;