adding size param
authorVolker Birk <vb@pep-project.org>
Tue, 12 May 2015 16:33:00 +0200
changeset 2697eb06a6984fe
parent 268 9a25a837dc27
child 273 1017daf29ff4
child 274 892d07b825f6
adding size param
src/message_api.c
src/mime.c
src/mime.h
     1.1 --- a/src/message_api.c	Tue May 12 16:29:58 2015 +0200
     1.2 +++ b/src/message_api.c	Tue May 12 16:33:00 2015 +0200
     1.3 @@ -803,7 +803,7 @@
     1.4      message *msg = NULL;
     1.5      char *ctext;
     1.6      size_t csize;
     1.7 -    char *ptext;
     1.8 +    char *ptext = NULL;
     1.9      size_t psize;
    1.10      stringlist_t *_keylist = NULL;
    1.11      bool free_src = false;
    1.12 @@ -825,9 +825,13 @@
    1.13      *color = PEP_rating_undefined;
    1.14   
    1.15      switch (src->enc_format) {
    1.16 +        case PEP_enc_none:
    1.17 +            status = PEP_UNENCRYPTED;
    1.18 +            break;
    1.19 +
    1.20          case PEP_enc_PGP_MIME:
    1.21              ctext = src->attachments->next->data;
    1.22 -            csize = strlen(ctext);
    1.23 +            csize = src->attachments->next->size;
    1.24  
    1.25              status = cryptotech[crypto].decrypt_and_verify(session, ctext,
    1.26                      csize, &ptext, &psize, &_keylist);
    1.27 @@ -874,7 +878,7 @@
    1.28      if (ptext) {
    1.29          switch (src->enc_format) {
    1.30              case PEP_enc_PGP_MIME:
    1.31 -                status = mime_decode_message(ptext, &msg);
    1.32 +                status = mime_decode_message(ptext, psize, &msg);
    1.33                  if (status != PEP_STATUS_OK)
    1.34                      goto pep_error;
    1.35                  break;
     2.1 --- a/src/mime.c	Tue May 12 16:29:58 2015 +0200
     2.2 +++ b/src/mime.c	Tue May 12 16:33:00 2015 +0200
     2.3 @@ -1391,6 +1391,7 @@
     2.4  
     2.5  DYNAMIC_API PEP_STATUS mime_decode_message(
     2.6          const char *mimetext,
     2.7 +        size_t size,
     2.8          message **msg
     2.9      )
    2.10  {
    2.11 @@ -1409,7 +1410,7 @@
    2.12      *msg = NULL;
    2.13  
    2.14      index = 0;
    2.15 -    r = mailmime_parse(mimetext, strlen(mimetext), &index, &mime);
    2.16 +    r = mailmime_parse(mimetext, size, &index, &mime);
    2.17      assert(r == 0);
    2.18      assert(mime);
    2.19      if (r) {
     3.1 --- a/src/mime.h	Tue May 12 16:29:58 2015 +0200
     3.2 +++ b/src/mime.h	Tue May 12 16:33:00 2015 +0200
     3.3 @@ -50,6 +50,7 @@
     3.4  //
     3.5  //  parameters:
     3.6  //      mimetext (in)           MIME encoded text to decode
     3.7 +//      size (in)               size of text to decode
     3.8  //      msg (out)               decoded message
     3.9  //
    3.10  //  return value:
    3.11 @@ -67,6 +68,7 @@
    3.12  
    3.13  DYNAMIC_API PEP_STATUS mime_decode_message(
    3.14          const char *mimetext,
    3.15 +        size_t size,
    3.16          message **msg
    3.17      );
    3.18