merge "default" into my branch roker-linux
authorRoker <roker@pep-project.org>
Wed, 29 Jun 2016 13:23:20 +0200
branchroker-linux
changeset 7782740958d5401
parent 777 3f6704f9dcde
parent 771 c04f54a73ef8
child 779 cecbd66421f6
merge "default" into my branch
test/Makefile
     1.1 --- a/.hgignore	Wed Jun 29 13:23:04 2016 +0200
     1.2 +++ b/.hgignore	Wed Jun 29 13:23:20 2016 +0200
     1.3 @@ -27,6 +27,7 @@
     1.4  build-android/pEpEngine-android-1.zip
     1.5  build-android/third-party
     1.6  build-android/pEpEngine-android-1
     1.7 +build-linux/*
     1.8  *.dSYM*
     1.9  *_test
    1.10  msg4.asc
     2.1 --- a/src/message_api.c	Wed Jun 29 13:23:04 2016 +0200
     2.2 +++ b/src/message_api.c	Wed Jun 29 13:23:20 2016 +0200
     2.3 @@ -496,46 +496,53 @@
     2.4          bloblist_t *_s = src->attachments;
     2.5          bloblist_t *_d = dst->attachments;
     2.6  
     2.7 -        for (int n = 0; _s && _s->value; _s = _s->next) {
     2.8 -            size_t psize = _s->size;
     2.9 -            ptext = _s->value;
    2.10 -            status = encrypt_and_sign(session, keys, ptext, psize, &ctext,
    2.11 -                &csize);
    2.12 -            if (ctext) {
    2.13 -                char *filename = NULL;
    2.14 -
    2.15 -                if (_s->filename) {
    2.16 -                    size_t len = strlen(_s->filename);
    2.17 -                    filename = calloc(1, len + 5);
    2.18 -                    if (filename == NULL)
    2.19 -                        goto enomem;
    2.20 -
    2.21 -                    strcpy(filename, _s->filename);
    2.22 -                    strcpy(filename + len, ".pgp");
    2.23 -                }
    2.24 -                else {
    2.25 -                    filename = calloc(1, 20);
    2.26 -                    if (filename == NULL)
    2.27 -                        goto enomem;
    2.28 -
    2.29 -                    ++n;
    2.30 -                    n &= 0xffff;
    2.31 -                    snprintf(filename, 20, "Attachment%d.pgp", n);
    2.32 -                }
    2.33 -
    2.34 -                char *_ctext = malloc(csize);
    2.35 -                assert(_ctext);
    2.36 -                if (_ctext == NULL)
    2.37 -                    goto enomem;
    2.38 -                memcpy(_ctext, ctext, csize);
    2.39 -
    2.40 -                _d = bloblist_add(_d, _ctext, csize, "application/octet-stream",
    2.41 -                    filename);
    2.42 +        for (int n = 0; _s; _s = _s->next) {
    2.43 +            if (_s->value == NULL && _s->size == 0) {
    2.44 +                _d = bloblist_add(_d, NULL, 0, _s->mime_type, _s->filename);
    2.45                  if (_d == NULL)
    2.46                      goto enomem;
    2.47              }
    2.48              else {
    2.49 -                goto pep_error;
    2.50 +                size_t psize = _s->size;
    2.51 +                ptext = _s->value;
    2.52 +                status = encrypt_and_sign(session, keys, ptext, psize, &ctext,
    2.53 +                    &csize);
    2.54 +                if (ctext) {
    2.55 +                    char *filename = NULL;
    2.56 +
    2.57 +                    if (_s->filename) {
    2.58 +                        size_t len = strlen(_s->filename);
    2.59 +                        filename = calloc(1, len + 5);
    2.60 +                        if (filename == NULL)
    2.61 +                            goto enomem;
    2.62 +
    2.63 +                        strcpy(filename, _s->filename);
    2.64 +                        strcpy(filename + len, ".pgp");
    2.65 +                    }
    2.66 +                    else {
    2.67 +                        filename = calloc(1, 20);
    2.68 +                        if (filename == NULL)
    2.69 +                            goto enomem;
    2.70 +
    2.71 +                        ++n;
    2.72 +                        n &= 0xffff;
    2.73 +                        snprintf(filename, 20, "Attachment%d.pgp", n);
    2.74 +                    }
    2.75 +
    2.76 +                    char *_ctext = malloc(csize);
    2.77 +                    assert(_ctext);
    2.78 +                    if (_ctext == NULL)
    2.79 +                        goto enomem;
    2.80 +                    memcpy(_ctext, ctext, csize);
    2.81 +
    2.82 +                    _d = bloblist_add(_d, _ctext, csize, "application/octet-stream",
    2.83 +                        filename);
    2.84 +                    if (_d == NULL)
    2.85 +                        goto enomem;
    2.86 +                }
    2.87 +                else {
    2.88 +                    goto pep_error;
    2.89 +                }
    2.90              }
    2.91          }
    2.92      }
    2.93 @@ -1273,8 +1280,14 @@
    2.94                  }
    2.95  
    2.96                  bloblist_t *_s;
    2.97 -                for (_s = src->attachments; _s && _s->value; _s = _s->next) {
    2.98 -                    if (is_encrypted_attachment(_s)) {
    2.99 +                for (_s = src->attachments; _s; _s = _s->next) {
   2.100 +                    if (_s->value == NULL && _s->size == 0){
   2.101 +                        _m = bloblist_add(_m, NULL, 0, _s->mime_type, _s->filename);
   2.102 +                        if (_m == NULL)
   2.103 +                            goto enomem;
   2.104 +
   2.105 +                    }
   2.106 +                    else if (is_encrypted_attachment(_s)) {
   2.107                          stringlist_t *_keylist = NULL;
   2.108                          char *attctext;
   2.109                          size_t attcsize;
     3.1 --- a/src/mime.c	Wed Jun 29 13:23:04 2016 +0200
     3.2 +++ b/src/mime.c	Wed Jun 29 13:23:20 2016 +0200
     3.3 @@ -693,8 +693,6 @@
     3.4  
     3.5          bloblist_t *_a;
     3.6          for (_a = msg->attachments; _a != NULL; _a = _a->next) {
     3.7 -            //assert(_a->value);
     3.8 -            //assert(_a->size);
     3.9  
    3.10              status = mime_attachment(_a, &submime);
    3.11              if (status != PEP_STATUS_OK)
     4.1 --- a/test/Makefile	Wed Jun 29 13:23:04 2016 +0200
     4.2 +++ b/test/Makefile	Wed Jun 29 13:23:20 2016 +0200
     4.3 @@ -35,6 +35,9 @@
     4.4  %_test_lldb : %_test
     4.5  	LD_LIBRARY_PATH=~/lib:../src lldb ./$<
     4.6  
     4.7 +%_test_gdb : %_test
     4.8 +	LD_LIBRARY_PATH=~/lib:../src gdb ./$<
     4.9 +
    4.10  unit_tests: $(UNIT_TESTS) $(UNIT_TESTS_RUN)
    4.11  
    4.12  install: