Changeset 559076c for functions.c


Ignore:
Timestamp:
Sep 15, 2008, 11:43:56 PM (16 years ago)
Author:
Alejandro R. Sedeño <asedeno@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
7ba9ead9
Parents:
c194705
Message:
Fix the zcrypt bug.

This should fix the segfault on short zcrpyt messages.

As added bonuses, it documents the length of the cryptmsg buffer and
plugs a small memory leak.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • functions.c

    r740d5f7 r559076c  
    422422  mymsg=owl_zwrite_get_message(&z);
    423423#ifdef OWL_ENABLE_ZCRYPT
    424   cryptmsg=owl_malloc(strlen(mymsg)*4);
     424  /* Allocate enough space for the crypted message. For each byte of
     425   * the message, the encoded cyphertext will have two bytes. Block
     426   * size is 8 bytes of input, or 16 bytes of output, so make sure we
     427   * have at least one block worth of space allocated. If the message
     428   * is empty, no blocks are sent, but we still allocate one
     429   * block. The additional 16 bytes also provide space for the null
     430   * terminator, as we will never use all of it for cyphertext.
     431   */
     432  cryptmsg=owl_malloc((strlen(mymsg)*2)+16);
    425433  ret=owl_zcrypt_encrypt(cryptmsg, mymsg, owl_zwrite_get_class(&z), owl_zwrite_get_instance(&z));
    426434  if (ret) {
     
    428436    owl_function_beep();
    429437    owl_free(cryptmsg);
     438    owl_zwrite_free(&z);
    430439    return;
    431440  }
Note: See TracChangeset for help on using the changeset viewer.