message format
authorvb
Wed, 31 Dec 2014 00:19:21 +0100
changeset 43816f4ccf84da
parent 42 d7263ab3b539
child 44 4013b57a6a69
message format
src/message_api.c
     1.1 --- a/src/message_api.c	Tue Dec 30 23:35:24 2014 +0100
     1.2 +++ b/src/message_api.c	Wed Dec 31 00:19:21 2014 +0100
     1.3 @@ -20,7 +20,6 @@
     1.4  
     1.5      assert(session);
     1.6      assert(src);
     1.7 -    assert(src->shortmsg || src->longmsg);
     1.8      assert(dst);
     1.9      *dst = NULL;
    1.10      assert(format != PEP_enc_none);
    1.11 @@ -126,9 +125,18 @@
    1.12                  }
    1.13              }
    1.14              else if (src->shortmsg) {
    1.15 -                ptext = src->shortmsg;
    1.16 +                ptext = calloc(1, strlen(src->shortmsg) + 12);
    1.17 +                if (ptext == NULL) {
    1.18 +                    free_message(msg);
    1.19 +                    free_stringlist(keys);
    1.20 +                    return PEP_OUT_OF_MEMORY;
    1.21 +                }
    1.22 +                strcpy(ptext, "subject: ");
    1.23 +                strcat(ptext, src->shortmsg);
    1.24 +                strcat(ptext, "\n\n");
    1.25                  status = encrypt_and_sign(session, keys, ptext, strlen(ptext),
    1.26                          &ctext, &csize);
    1.27 +                free(ptext);
    1.28                  if (ctext) {
    1.29                      msg->longmsg = strdup(ctext);
    1.30                      msg->shortmsg = strdup("pEp");