Changeset 54e1fe4 for functions.c


Ignore:
Timestamp:
Mar 1, 2010, 8:33:48 PM (11 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
release-1.5
Children:
8fff19a
Parents:
b381b55
git-author:
Anders Kaseorg <andersk@mit.edu> (02/07/10 22:55:21)
git-committer:
Nelson Elhage <nelhage@mit.edu> (03/01/10 20:33:48)
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

    rcce5dbd r54e1fe4  
    425425  char *cryptmsg;
    426426  owl_message *m;
    427 #ifdef OWL_ENABLE_ZCRYPT
    428   int ret;
    429 #endif
    430427
    431428  /* create the zwrite and send the message */
     
    438435  mymsg=owl_zwrite_get_message(&z);
    439436#ifdef OWL_ENABLE_ZCRYPT
    440   /* Allocate enough space for the crypted message. For each byte of
    441    * the message, the encoded cyphertext will have two bytes. Block
    442    * size is 8 bytes of input, or 16 bytes of output, so make sure we
    443    * have at least one block worth of space allocated. If the message
    444    * is empty, no blocks are sent, but we still allocate one
    445    * block. The additional 16 bytes also provide space for the null
    446    * terminator, as we will never use all of it for cyphertext.
    447    */
    448   cryptmsg=owl_malloc((strlen(mymsg)*2)+16);
    449   ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    450   if (ret) {
     437  cryptmsg = owl_zcrypt_encrypt(mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
     438  if (!cryptmsg) {
    451439    owl_function_error("Error in zcrypt, possibly no key found.  Message not sent.");
    452440    owl_function_beep();
    453     owl_free(cryptmsg);
    454441    owl_zwrite_free(&z);
    455442    return;
Note: See TracChangeset for help on using the changeset viewer.