merging
authorVolker Birk <vb@pep-project.org>
Sat, 16 Jul 2016 09:15:42 +0200
changeset 885ca89e40342d4
parent 884 d64d366512a0
parent 882 277297dadbb9
child 888 af49e1cd6d7a
merging
     1.1 --- a/Makefile	Sat Jul 16 09:15:33 2016 +0200
     1.2 +++ b/Makefile	Sat Jul 16 09:15:42 2016 +0200
     1.3 @@ -1,5 +1,9 @@
     1.4  include Makefile.conf
     1.5  
     1.6 +# add it to the environment of all executed programs:
     1.7 +export YML_PATH
     1.8 +
     1.9 +
    1.10  all:
    1.11  	$(MAKE) -C asn.1 generate
    1.12  	$(MAKE) -C asn.1
     2.1 --- a/src/blacklist.c	Sat Jul 16 09:15:33 2016 +0200
     2.2 +++ b/src/blacklist.c	Sat Jul 16 09:15:42 2016 +0200
     2.3 @@ -115,21 +115,21 @@
     2.4      sqlite3_reset(session->blacklist_retrieve);
     2.5  
     2.6      int result;
     2.7 -    const char *fpr = NULL;
     2.8  
     2.9      stringlist_t *_bl = _blacklist;
    2.10      do {
    2.11          result = sqlite3_step(session->blacklist_retrieve);
    2.12          switch (result) {
    2.13          case SQLITE_ROW:
    2.14 -            fpr = (const char *) sqlite3_column_text(session->blacklist_retrieve, 0);
    2.15 +        {
    2.16 +            const char *fpr = (const char *) sqlite3_column_text(session->blacklist_retrieve, 0);
    2.17  
    2.18              _bl = stringlist_add(_bl, fpr);
    2.19              if (_bl == NULL)
    2.20                  goto enomem;
    2.21  
    2.22              break;
    2.23 -
    2.24 +        }
    2.25          case SQLITE_DONE:
    2.26              break;
    2.27  
     3.1 --- a/src/message_api.c	Sat Jul 16 09:15:33 2016 +0200
     3.2 +++ b/src/message_api.c	Sat Jul 16 09:15:42 2016 +0200
     3.3 @@ -329,8 +329,7 @@
     3.4      PEP_STATUS status = PEP_STATUS_OK;
     3.5      bool free_ptext = false;
     3.6      char *ptext = NULL;
     3.7 -    char *ctext;
     3.8 -    char *_ctext = NULL;
     3.9 +    char *ctext = NULL;
    3.10      char *mimetext = NULL;
    3.11      size_t csize;
    3.12      assert(dst->longmsg == NULL);
    3.13 @@ -402,13 +401,7 @@
    3.14          goto enomem;
    3.15      dst->attachments = _a;
    3.16  
    3.17 -    _ctext = malloc(csize);
    3.18 -    assert(_ctext);
    3.19 -    if (_ctext == NULL)
    3.20 -        goto enomem;
    3.21 -    memcpy(_ctext, ctext, csize);
    3.22 -
    3.23 -    _a = bloblist_add(_a, _ctext, csize, "application/octet-stream",
    3.24 +    _a = bloblist_add(_a, ctext, csize, "application/octet-stream",
    3.25          "msg.asc");
    3.26      if (_a == NULL)
    3.27          goto enomem;
    3.28 @@ -421,7 +414,7 @@
    3.29  pep_error:
    3.30      if (free_ptext)
    3.31          free(ptext);
    3.32 -    free(_ctext);
    3.33 +    free(ctext);
    3.34      return status;
    3.35  }
    3.36  
    3.37 @@ -433,7 +426,7 @@
    3.38      )
    3.39  {
    3.40      PEP_STATUS status = PEP_STATUS_OK;
    3.41 -    char *ctext;
    3.42 +    char *ctext = NULL;
    3.43      size_t csize;
    3.44      char *ptext = NULL;
    3.45      bool free_ptext = false;
    3.46 @@ -464,10 +457,7 @@
    3.47              free(ptext);
    3.48          free_ptext = false;
    3.49          if (ctext) {
    3.50 -            dst->longmsg = strndup(ctext, csize);
    3.51 -            assert(dst->longmsg);
    3.52 -            if (dst->longmsg == NULL)
    3.53 -                goto enomem;
    3.54 +            dst->longmsg = ctext;
    3.55          }
    3.56          else {
    3.57              goto pep_error;
    3.58 @@ -478,10 +468,7 @@
    3.59          status = encrypt_and_sign(session, keys, ptext, strlen(ptext), &ctext,
    3.60              &csize);
    3.61          if (ctext) {
    3.62 -            dst->longmsg = strndup(ctext, csize);
    3.63 -            assert(dst->longmsg);
    3.64 -            if (dst->longmsg == NULL)
    3.65 -                goto enomem;
    3.66 +            dst->longmsg = ctext;
    3.67          }
    3.68          else {
    3.69              goto pep_error;
    3.70 @@ -499,13 +486,8 @@
    3.71          status = encrypt_and_sign(session, keys, ptext, strlen(ptext), &ctext,
    3.72              &csize);
    3.73          if (ctext) {
    3.74 -            char *_ctext = malloc(csize);
    3.75 -            assert(_ctext);
    3.76 -            if (_ctext == NULL)
    3.77 -                goto enomem;
    3.78 -            memcpy(_ctext, ctext, csize);
    3.79  
    3.80 -            bloblist_t *_a = bloblist_add(dst->attachments, _ctext, csize,
    3.81 +            bloblist_t *_a = bloblist_add(dst->attachments, ctext, csize,
    3.82                  "application/octet-stream", "PGPexch.htm.pgp");
    3.83              if (_a == NULL)
    3.84                  goto enomem;
    3.85 @@ -560,15 +542,7 @@
    3.86                          snprintf(filename, 20, "Attachment%d.pgp", n);
    3.87                      }
    3.88  
    3.89 -                    char *_ctext = malloc(csize);
    3.90 -                    assert(_ctext);
    3.91 -                    if (_ctext == NULL) {
    3.92 -                        free(filename);
    3.93 -                        goto enomem;
    3.94 -                    }
    3.95 -                    memcpy(_ctext, ctext, csize);
    3.96 -
    3.97 -                    _d = bloblist_add(_d, _ctext, csize, "application/octet-stream",
    3.98 +                    _d = bloblist_add(_d, ctext, csize, "application/octet-stream",
    3.99                          filename);
   3.100                      free(filename);
   3.101                      if (_d == NULL)
   3.102 @@ -1346,10 +1320,8 @@
   3.103                  if (msg == NULL)
   3.104                      goto enomem;
   3.105  
   3.106 -                msg->longmsg = strdup(ptext);
   3.107 -                assert(msg->longmsg);
   3.108 -                if (msg->longmsg == NULL)
   3.109 -                    goto enomem;
   3.110 +                msg->longmsg = ptext;
   3.111 +                ptext = NULL;
   3.112  
   3.113                  bloblist_t *_m = msg->attachments;
   3.114                  if (_m == NULL && src->attachments && src->attachments->value) {
   3.115 @@ -1379,10 +1351,8 @@
   3.116  
   3.117                          if (ptext) {
   3.118                              if (is_encrypted_html_attachment(_s)) {
   3.119 -                                msg->longmsg_formatted = strdup(ptext);
   3.120 -                                assert(msg->longmsg_formatted);
   3.121 -                                if (msg->longmsg_formatted == NULL)
   3.122 -                                    goto pep_error;
   3.123 +                                msg->longmsg_formatted = ptext;
   3.124 +                                ptext = NULL;
   3.125                              }
   3.126                              else {
   3.127                                  static const char * const mime_type = "application/octet-stream";
   3.128 @@ -1391,18 +1361,14 @@
   3.129                                  if (filename == NULL)
   3.130                                      goto enomem;
   3.131  
   3.132 -                                char *_ptext = malloc(psize);
   3.133 -                                assert(_ptext);
   3.134 -                                if (_ptext == NULL)
   3.135 -                                    goto enomem;
   3.136 -                                memcpy(_ptext, ptext, psize);
   3.137 -
   3.138 -                                _m = bloblist_add(_m, _ptext, psize, mime_type,
   3.139 +                                _m = bloblist_add(_m, ptext, psize, mime_type,
   3.140                                      filename);
   3.141                                  free(filename);
   3.142                                  if (_m == NULL)
   3.143                                      goto enomem;
   3.144  
   3.145 +                                ptext = NULL;
   3.146 +
   3.147                                  if (msg->attachments == NULL)
   3.148                                      msg->attachments = _m;
   3.149                              }
   3.150 @@ -1512,8 +1478,7 @@
   3.151              status = cryptotech[crypto].decrypt_and_verify(session, ctext,
   3.152                  csize, &re_ptext, &re_psize, &_keylist);
   3.153              
   3.154 -            if (re_ptext)
   3.155 -                free(re_ptext);
   3.156 +            free(re_ptext);
   3.157              
   3.158              if (status > PEP_CANNOT_DECRYPT_UNKNOWN)
   3.159                  goto pep_error;
   3.160 @@ -1591,6 +1556,7 @@
   3.161      status = PEP_OUT_OF_MEMORY;
   3.162  
   3.163  pep_error:
   3.164 +    free(ptext);
   3.165      free_message(msg);
   3.166      free_stringlist(_keylist);
   3.167  
     4.1 --- a/src/pEpEngine.c	Sat Jul 16 09:15:33 2016 +0200
     4.2 +++ b/src/pEpEngine.c	Sat Jul 16 09:15:42 2016 +0200
     4.3 @@ -564,7 +564,6 @@
     4.4          )
     4.5  {
     4.6      PEP_STATUS status = PEP_STATUS_OK;
     4.7 -    int result;
     4.8  
     4.9      assert(session);
    4.10      assert(word);
    4.11 @@ -589,7 +588,7 @@
    4.12      sqlite3_bind_text(session->trustword, 1, lang, -1, SQLITE_STATIC);
    4.13      sqlite3_bind_int(session->trustword, 2, value);
    4.14  
    4.15 -    result = sqlite3_step(session->trustword);
    4.16 +    const int result = sqlite3_step(session->trustword);
    4.17      if (result == SQLITE_ROW) {
    4.18          *word = strdup((const char *) sqlite3_column_text(session->trustword,
    4.19                      1));
    4.20 @@ -778,8 +777,6 @@
    4.21  {
    4.22      PEP_STATUS status = PEP_STATUS_OK;
    4.23      static pEp_identity *_identity;
    4.24 -    int result;
    4.25 -    const char *_lang;
    4.26  
    4.27      assert(session);
    4.28      assert(address);
    4.29 @@ -795,7 +792,7 @@
    4.30      sqlite3_bind_text(session->get_identity, 1, address, -1, SQLITE_STATIC);
    4.31      sqlite3_bind_text(session->get_identity, 2, user_id, -1, SQLITE_STATIC);
    4.32  
    4.33 -    result = sqlite3_step(session->get_identity);
    4.34 +    const int result = sqlite3_step(session->get_identity);
    4.35      switch (result) {
    4.36      case SQLITE_ROW:
    4.37          _identity = new_identity(
    4.38 @@ -809,7 +806,7 @@
    4.39              return PEP_OUT_OF_MEMORY;
    4.40  
    4.41          _identity->comm_type = (PEP_comm_type) sqlite3_column_int(session->get_identity, 2);
    4.42 -        _lang = (const char *) sqlite3_column_text(session->get_identity, 3);
    4.43 +        const char* const _lang = (const char *) sqlite3_column_text(session->get_identity, 3);
    4.44          if (_lang && _lang[0]) {
    4.45              assert(_lang[0] >= 'a' && _lang[0] <= 'z');
    4.46              assert(_lang[1] >= 'a' && _lang[1] <= 'z');
     5.1 --- a/src/pgp_gpg.c	Sat Jul 16 09:15:33 2016 +0200
     5.2 +++ b/src/pgp_gpg.c	Sat Jul 16 09:15:42 2016 +0200
     5.3 @@ -95,7 +95,6 @@
     5.4      PEP_STATUS status = PEP_STATUS_OK;
     5.5      gpgme_error_t gpgme_error;
     5.6      bool bResult;
     5.7 -    char *cLocal;
     5.8      
     5.9      if (in_first) {
    5.10          stringlist_t *conf_keys   = new_stringlist("keyserver");
    5.11 @@ -333,7 +332,7 @@
    5.12  
    5.13          gpg.version = gpg.gpgme_check(NULL);
    5.14          
    5.15 -        cLocal = setlocale(LC_ALL, NULL);
    5.16 +        const char * const cLocal = setlocale(LC_ALL, NULL);
    5.17          if (!cLocal || (strcmp(cLocal, "C") == 0))
    5.18              setlocale(LC_ALL, "");
    5.19  
    5.20 @@ -1314,8 +1313,6 @@
    5.21  {
    5.22      gpgme_error_t gpgme_error;
    5.23      gpgme_key_t key;
    5.24 -    stringlist_t *_keylist;
    5.25 -    char *fpr;
    5.26  
    5.27      assert(session);
    5.28      assert(pattern);
    5.29 @@ -1336,7 +1333,7 @@
    5.30          return PEP_GET_KEY_FAILED;
    5.31      };
    5.32  
    5.33 -    _keylist = new_stringlist(NULL);
    5.34 +    stringlist_t *_keylist = new_stringlist(NULL);
    5.35      stringlist_t *_k = _keylist;
    5.36  
    5.37      do {
    5.38 @@ -1349,7 +1346,7 @@
    5.39          case GPG_ERR_NO_ERROR:
    5.40              assert(key);
    5.41              assert(key->subkeys);
    5.42 -            fpr = key->subkeys->fpr;
    5.43 +            char *fpr = key->subkeys->fpr;
    5.44              assert(fpr);
    5.45              _k = stringlist_add(_k, fpr);
    5.46              assert(_k);