rational
authorvb
Sun, 01 Mar 2015 01:07:35 +0100
changeset 80b12ce95403a1
parent 79 2363a3f35fd2
child 81 044ce1c7fc9c
rational
src/message_api.c
src/pgp_gpg.c
src/platform_windows.cpp
src/platform_windows.h
     1.1 --- a/src/message_api.c	Thu Feb 26 16:17:19 2015 +0100
     1.2 +++ b/src/message_api.c	Sun Mar 01 01:07:35 2015 +0100
     1.3 @@ -32,6 +32,37 @@
     1.4      return ptext;
     1.5  }
     1.6  
     1.7 +static message * clone_empty_message(const message * src)
     1.8 +{
     1.9 +    pEp_identity *from = NULL;
    1.10 +    identity_list *to = NULL;
    1.11 +    message * msg = NULL;
    1.12 +
    1.13 +    from = identity_dup(src->from);
    1.14 +    assert(from);
    1.15 +    if (from == NULL)
    1.16 +        goto enomem;
    1.17 +
    1.18 +    from->me = true;
    1.19 +
    1.20 +    to = identity_list_dup(src->to);
    1.21 +    assert(to);
    1.22 +    if (to == NULL)
    1.23 +        goto enomem;
    1.24 +
    1.25 +    msg = new_message(src->dir, from, to, NULL);
    1.26 +    assert(msg);
    1.27 +    if (msg == NULL)
    1.28 +        goto enomem;
    1.29 +
    1.30 +    return msg;
    1.31 +
    1.32 +enomem:
    1.33 +    free_identity(from);
    1.34 +    free_identity_list(to);
    1.35 +    return NULL;
    1.36 +}
    1.37 +
    1.38  DYNAMIC_API PEP_STATUS encrypt_message(
    1.39          PEP_SESSION session,
    1.40          const message *src,
    1.41 @@ -55,30 +86,17 @@
    1.42          NOT_IMPLEMENTED   
    1.43      }
    1.44  
    1.45 -    pEp_identity *from = identity_dup(src->from);
    1.46 -    if (from == NULL)
    1.47 +    msg = clone_empty_message(src);
    1.48 +    if (msg == NULL)
    1.49          goto enomem;
    1.50 -    from->me = true;
    1.51  
    1.52 -    identity_list *to = identity_list_dup(src->to);
    1.53 -    if (to == NULL) {
    1.54 -        free_identity(from);
    1.55 -        goto enomem;
    1.56 -    }
    1.57 -
    1.58 -    msg = new_message(src->dir, from, to, NULL);
    1.59 -    if (msg == NULL) {
    1.60 -        free_identity(from);
    1.61 -        free_identity_list(to);
    1.62 -        goto enomem;
    1.63 -    }
    1.64      msg->enc_format = PEP_enc_pieces;
    1.65  
    1.66 -    status = myself(session, from);
    1.67 +    status = myself(session, src->from);
    1.68      if (status != PEP_STATUS_OK)
    1.69          goto pep_error;
    1.70  
    1.71 -    keys = new_stringlist(from->fpr);
    1.72 +    keys = new_stringlist(src->from->fpr);
    1.73      if (keys == NULL)
    1.74          goto enomem;
    1.75  
    1.76 @@ -92,7 +110,7 @@
    1.77  
    1.78      bool dest_keys_found = false;
    1.79      identity_list * _il;
    1.80 -    for (_il = to; _il && _il->ident; _il = _il->next) {
    1.81 +    for (_il = msg->to; _il && _il->ident; _il = _il->next) {
    1.82          PEP_STATUS status = update_identity(session, _il->ident);
    1.83          if (status != PEP_STATUS_OK)
    1.84              goto pep_error;
     2.1 --- a/src/pgp_gpg.c	Thu Feb 26 16:17:19 2015 +0100
     2.2 +++ b/src/pgp_gpg.c	Sun Mar 01 01:07:35 2015 +0100
     2.3 @@ -42,10 +42,11 @@
     2.4                      return false;
     2.5  
     2.6                  if (s && !feof(f)) {
     2.7 -                    char * t = strtok(s, " ");
     2.8 +                    char * rest;
     2.9 +                    char * t = strtok_r(s, " ", &rest);
    2.10                      for (i = 1, _k = keys, _v = values; _k != NULL;
    2.11                              _k = _k->next, _v = _v->next, i <<= 1) {
    2.12 -                        if (t && strcmp(t, _k->value) == 0)
    2.13 +                        if (t && strncmp(t, _k->value, strlen(_k->value)) == 0)
    2.14                              found |= i;
    2.15  
    2.16                          if (i == n) {
    2.17 @@ -93,6 +94,18 @@
    2.18          stringlist_add(conf_keys, "cert-digest-algo");
    2.19          stringlist_add(conf_values, "SHA256");
    2.20  
    2.21 +        stringlist_add(conf_keys, "no-emit-version");
    2.22 +        stringlist_add(conf_values, "");
    2.23 +
    2.24 +        stringlist_add(conf_keys, "no-comments");
    2.25 +        stringlist_add(conf_values, "");
    2.26 +
    2.27 +        stringlist_add(conf_keys, "personal-cipher-preferences");
    2.28 +        stringlist_add(conf_values, "AES AES256 AES192 CAST5");
    2.29 +
    2.30 +        stringlist_add(conf_keys, "personal-digest-preferences");
    2.31 +        stringlist_add(conf_values, "SHA512 SHA384 SHA256 SHA224");
    2.32 +        
    2.33          bResult = ensure_config_values(conf_keys, conf_values);
    2.34          assert(bResult);
    2.35  
     3.1 --- a/src/platform_windows.cpp	Thu Feb 26 16:17:19 2015 +0100
     3.2 +++ b/src/platform_windows.cpp	Sun Mar 01 01:07:35 2015 +0100
     3.3 @@ -10,6 +10,7 @@
     3.4  #define _CRT_RAND_S
     3.5  #include <stdlib.h>
     3.6  #include <assert.h>
     3.7 +#include <string.h>
     3.8  #include <string>
     3.9  #include <stdexcept>
    3.10  #include "platform_windows.h"
    3.11 @@ -202,5 +203,9 @@
    3.12      return (long) (r & ((1<<31)-1));
    3.13  }
    3.14  
    3.15 +#ifndef strtok_r
    3.16 +#define strtok_r(A, B, C) strtok_s((A), (B), (C))
    3.17 +#endif
    3.18 +
    3.19  } // "C"
    3.20  
     4.1 --- a/src/platform_windows.h	Thu Feb 26 16:17:19 2015 +0100
     4.2 +++ b/src/platform_windows.h	Sun Mar 01 01:07:35 2015 +0100
     4.3 @@ -19,6 +19,12 @@
     4.4  int dlclose(void *handle);
     4.5  void *dlsym(void *handle, const char *symbol);
     4.6  
     4.7 +char *strtok_r(
     4.8 +        char *restrict str,
     4.9 +        const char *restrict sep,
    4.10 +        char **restrict lasts
    4.11 +    );
    4.12 +
    4.13  const char *windoze_local_db(void);
    4.14  const char *windoze_system_db(void);
    4.15  const char *gpg_conf(void);