ENGINE-557: crap, had checked in some bad stuff from before I understood the problem that I didn't know was still there. Anyway, we're good AFAICS now. sync
authorKrista 'DarthMama' Bennett <krista@pep.foundation>
Wed, 15 May 2019 13:59:55 +0200
branchsync
changeset 3682df9823cb0d96
parent 3681 120b329e558a
child 3683 c6914bf63ee4
ENGINE-557: crap, had checked in some bad stuff from before I understood the problem that I didn't know was still there. Anyway, we're good AFAICS now.
src/pgp_sequoia.c
     1.1 --- a/src/pgp_sequoia.c	Wed May 15 12:53:34 2019 +0200
     1.2 +++ b/src/pgp_sequoia.c	Wed May 15 13:59:55 2019 +0200
     1.3 @@ -9,7 +9,6 @@
     1.4  #include "pEp_internal.h"
     1.5  #include "pgp_gpg.h"
     1.6  
     1.7 -#include <ctype.h>
     1.8  #include <limits.h>
     1.9  #include <sys/stat.h>
    1.10  #include <sys/types.h>
    1.11 @@ -740,17 +739,17 @@
    1.12          pgp_packet_t userid = pgp_user_id_new (user_id_value);
    1.13          pgp_user_id_name(NULL, userid, &name);
    1.14          pgp_user_id_address(NULL, userid, &email);
    1.15 -        
    1.16 +                
    1.17          if (!email || email[0] == '\0') {
    1.18              size_t uid_value_len;
    1.19              const char* uid_value = (const char*)pgp_user_id_value(userid, &uid_value_len);
    1.20              if (!uid_value) {
    1.21                  // We need some kind of an error here, maybe?
    1.22 -                
    1.23 +                 
    1.24              }
    1.25              else {
    1.26                  const char* split = strstr(uid_value, "<");
    1.27 -                if (split != uid_value) {                    
    1.28 +                if (split != uid_value) {       
    1.29                      while (split) {
    1.30                          if (isspace(*(split - 1)))
    1.31                              break;
    1.32 @@ -761,7 +760,7 @@
    1.33                      char* stopchr = strrchr(split, '>');
    1.34                      if (stopchr) {
    1.35                          int email_len = stopchr - split - 1;
    1.36 -                        email = calloc(email_len + 1, 1);                                
    1.37 +                        email = calloc(email_len + 1, 1); 
    1.38                          strlcpy(email, split + 1, email_len + 1);
    1.39                          const char* last = NULL;
    1.40                          if (split != uid_value) {
    1.41 @@ -774,7 +773,7 @@
    1.42                              strlcpy(name, uid_value, name_len + 1);
    1.43                          }
    1.44                      }
    1.45 -                    else 
    1.46 +                    else  
    1.47                          split = NULL;
    1.48                  }
    1.49                  if (split == NULL) {
    1.50 @@ -782,6 +781,7 @@
    1.51                  }
    1.52              }
    1.53          }
    1.54 +        
    1.55          pgp_packet_free(userid);
    1.56          free(user_id_value);
    1.57  
    1.58 @@ -2047,49 +2047,36 @@
    1.59                      PEP_STATUS status = list_keys(session, undotted, private_only,
    1.60                                                    keyinfo_list, keylist);
    1.61                      free(undotted);
    1.62 -                    if (*keylist)
    1.63 -                        return status;
    1.64 +                    return status;
    1.65                  }
    1.66              }
    1.67          }
    1.68 -    } 
    1.69 -    if (!_keylist && !_keyinfo_list) {
    1.70 -        if (// Only hex characters and spaces
    1.71 -                   pattern[strspn(pattern, "0123456789aAbBcCdDeEfF ")] == 0
    1.72 -                   // And a fair amount of them.
    1.73 -                   && strlen(pattern) >= 16) {
    1.74 -            // Fingerprint.  Note: the pep engine never looks keys up by
    1.75 -            // keyid, so we don't handle them.
    1.76 -            fpr = pgp_fingerprint_from_hex(pattern);
    1.77 -            status = tpk_find_by_fpr(session, fpr, false, &tpk, NULL);
    1.78 -            ERROR_OUT(NULL, status, "Looking up key");
    1.79 -            add_key(session, _keyinfo_list, _keylist, tpk, fpr);
    1.80 -        } else if (pattern[0] == 0) {
    1.81 -            // Empty string.
    1.82 +    } else if (// Only hex characters and spaces
    1.83 +               pattern[strspn(pattern, "0123456789aAbBcCdDeEfF ")] == 0
    1.84 +               // And a fair amount of them.
    1.85 +               && strlen(pattern) >= 16) {
    1.86 +        // Fingerprint.  Note: the pep engine never looks keys up by
    1.87 +        // keyid, so we don't handle them.
    1.88 +        fpr = pgp_fingerprint_from_hex(pattern);
    1.89 +        status = tpk_find_by_fpr(session, fpr, false, &tpk, NULL);
    1.90 +        ERROR_OUT(NULL, status, "Looking up key");
    1.91 +        add_key(session, _keyinfo_list, _keylist, tpk, fpr);
    1.92 +    } else if (pattern[0] == 0) {
    1.93 +        // Empty string.
    1.94  
    1.95 -            pgp_tpk_t *tpks = NULL;
    1.96 -            int count = 0;
    1.97 -            status = tpk_all(session, private_only, &tpks, &count);
    1.98 -            ERROR_OUT(NULL, status, "Looking up '%s'", pattern);
    1.99 -            for (int i = 0; i < count; i ++) {
   1.100 -                add_key(session, _keyinfo_list, _keylist, tpks[i], NULL);
   1.101 -                pgp_tpk_free(tpks[i]);
   1.102 -            }
   1.103 -            free(tpks);
   1.104 -        } else {
   1.105 -    //        T("unsupported pattern '%s'", pattern);
   1.106 -            // We look up whatever arbitrary string we have
   1.107 -            pgp_tpk_t *tpks = NULL;
   1.108 -            int count = 0;
   1.109 -            status = tpk_find_by_email(session, pattern, private_only, &tpks, &count);
   1.110 -            ERROR_OUT(NULL, status, "Looking up '%s'", pattern);
   1.111 -            for (int i = 0; i < count; i ++) {
   1.112 -                add_key(session, _keyinfo_list, _keylist, tpks[i], NULL);
   1.113 -                pgp_tpk_free(tpks[i]);
   1.114 -            }
   1.115 -            free(tpks);
   1.116 +        pgp_tpk_t *tpks = NULL;
   1.117 +        int count = 0;
   1.118 +        status = tpk_all(session, private_only, &tpks, &count);
   1.119 +        ERROR_OUT(NULL, status, "Looking up '%s'", pattern);
   1.120 +        for (int i = 0; i < count; i ++) {
   1.121 +            add_key(session, _keyinfo_list, _keylist, tpks[i], NULL);
   1.122 +            pgp_tpk_free(tpks[i]);
   1.123          }
   1.124 +        free(tpks);
   1.125 +    } else {
   1.126 +        T("unsupported pattern '%s'", pattern);
   1.127      }
   1.128 +
   1.129   out:
   1.130      if (tpk)
   1.131          pgp_tpk_free(tpk);