Changeset dacb555 for functions.c


Ignore:
Timestamp:
Feb 9, 2010, 9:49:41 PM (14 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.6, release-1.7, release-1.8, release-1.9
Children:
a52eeb1
Parents:
d35d2ba
git-author:
Anders Kaseorg <andersk@mit.edu> (02/07/10 22:55:21)
git-committer:
Anders Kaseorg <andersk@mit.edu> (02/09/10 21:49:41)
Message:
zcrypt: Change zcrypt functions to allocate their output buffer.

The logic to determine the right buffer size is complicated and does
not belong in callers.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
Reviewed-by: Nelson Elhage <nelhage@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r2a17b63 rdacb555  
    406406  char *cryptmsg;
    407407  owl_message *m;
    408 #ifdef OWL_ENABLE_ZCRYPT
    409   int ret;
    410 #endif
    411408
    412409  /* create the zwrite and send the message */
     
    419416  mymsg=owl_zwrite_get_message(&z);
    420417#ifdef OWL_ENABLE_ZCRYPT
    421   /* Allocate enough space for the crypted message. For each byte of
    422    * the message, the encoded cyphertext will have two bytes. Block
    423    * size is 8 bytes of input, or 16 bytes of output, so make sure we
    424    * have at least one block worth of space allocated. If the message
    425    * is empty, no blocks are sent, but we still allocate one
    426    * block. The additional 16 bytes also provide space for the null
    427    * terminator, as we will never use all of it for cyphertext.
    428    */
    429   cryptmsg=owl_malloc((strlen(mymsg)*2)+16);
    430   ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    431   if (ret) {
     418  cryptmsg = owl_zcrypt_encrypt(mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
     419  if (!cryptmsg) {
    432420    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
    433421    owl_function_beep();
    434     owl_free(cryptmsg);
    435422    owl_zwrite_free(&z);
    436423    return;
Note: See TracChangeset for help on using the changeset viewer.