projects
/
apps
/
madmutt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Rocco Rutte:
[apps/madmutt.git]
/
gnupgparse.c
diff --git
a/gnupgparse.c
b/gnupgparse.c
index
099755d
..
c29ab84
100644
(file)
--- a/
gnupgparse.c
+++ b/
gnupgparse.c
@@
-40,6
+40,10
@@
/* for hexval */
#include "mime.h"
/* for hexval */
#include "mime.h"
+#include "lib/mem.h"
+#include "lib/str.h"
+#include "lib/debug.h"
+
/****************
* Read the GNUPG keys. For now we read the complete keyring by
* calling gnupg in a special mode.
/****************
* Read the GNUPG keys. For now we read the complete keyring by
* calling gnupg in a special mode.
@@
-84,7
+88,7
@@
static void fix_uid (char *uid)
char *ob;
size_t ibl, obl;
char *ob;
size_t ibl, obl;
- buf =
safe
_malloc (n + 1);
+ buf =
mem
_malloc (n + 1);
ib = uid, ibl = d - uid + 1, ob = buf, obl = n;
iconv (cd, &ib, &ibl, &ob, &obl);
if (!ibl) {
ib = uid, ibl = d - uid + 1, ob = buf, obl = n;
iconv (cd, &ib, &ibl, &ob, &obl);
if (!ibl) {
@@
-92,10
+96,10
@@
static void fix_uid (char *uid)
memcpy (uid, buf, ob - buf);
uid[ob - buf] = '\0';
}
memcpy (uid, buf, ob - buf);
uid[ob - buf] = '\0';
}
- else if (ob - buf == n && (buf[n] = 0, strlen (buf) < n))
+ else if (ob - buf == n && (buf[n] = 0, str
_
len (buf) < n))
memcpy (uid, buf, n);
}
memcpy (uid, buf, n);
}
-
FREE
(&buf);
+
mem_free
(&buf);
iconv_close (cd);
}
}
iconv_close (cd);
}
}
@@
-112,7
+116,7
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
if (!*buf)
return NULL;
if (!*buf)
return NULL;
- d
print (2, (debugfile, "parse_pub_line:
buf = `%s'\n", buf));
+ d
ebug_print (2, ("
buf = `%s'\n", buf));
for (p = buf; p; p = pend) {
if ((pend = strchr (p, ':')))
for (p = buf; p; p = pend) {
if ((pend = strchr (p, ':')))
@@
-124,27
+128,27
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
switch (field) {
case 1: /* record type */
{
switch (field) {
case 1: /* record type */
{
- d
print (2, (debugfile,
"record type: %s\n", p));
+ d
ebug_print (2, (
"record type: %s\n", p));
- if (!
mutt_str
cmp (p, "pub"));
- else if (!
mutt_str
cmp (p, "sub"))
+ if (!
str_
cmp (p, "pub"));
+ else if (!
str_
cmp (p, "sub"))
*is_subkey = 1;
*is_subkey = 1;
- else if (!
mutt_str
cmp (p, "sec"));
- else if (!
mutt_str
cmp (p, "ssb"))
+ else if (!
str_
cmp (p, "sec"));
+ else if (!
str_
cmp (p, "ssb"))
*is_subkey = 1;
*is_subkey = 1;
- else if (!
mutt_str
cmp (p, "uid"))
+ else if (!
str_
cmp (p, "uid"))
is_uid = 1;
else
return NULL;
if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
is_uid = 1;
else
return NULL;
if (!(is_uid || (*is_subkey && option (OPTPGPIGNORESUB))))
- k =
safe
_calloc (sizeof *k, 1);
+ k =
mem
_calloc (sizeof *k, 1);
break;
}
case 2: /* trust info */
{
break;
}
case 2: /* trust info */
{
- d
print (2, (debugfile,
"trust info: %s\n", p));
+ d
ebug_print (2, (
"trust info: %s\n", p));
switch (*p) { /* look only at the first letter */
case 'e':
switch (*p) { /* look only at the first letter */
case 'e':
@@
-178,7
+182,7
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
case 3: /* key length */
{
case 3: /* key length */
{
- d
print (2, (debugfile,
"key len: %s\n", p));
+ d
ebug_print (2, (
"key len: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
k->keylen = atoi (p); /* fixme: add validation checks */
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
k->keylen = atoi (p); /* fixme: add validation checks */
@@
-187,7
+191,7
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
case 4: /* pubkey algo */
{
case 4: /* pubkey algo */
{
- d
print (2, (debugfile,
"pubkey algorithm: %s\n", p));
+ d
ebug_print (2, (
"pubkey algorithm: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB))) {
k->numalg = atoi (p);
if (!(*is_subkey && option (OPTPGPIGNORESUB))) {
k->numalg = atoi (p);
@@
-197,10
+201,10
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
}
case 5: /* 16 hex digits with the long keyid. */
{
}
case 5: /* 16 hex digits with the long keyid. */
{
- d
print (2, (debugfile,
"key id: %s\n", p));
+ d
ebug_print (2, (
"key id: %s\n", p));
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
if (!(*is_subkey && option (OPTPGPIGNORESUB)))
-
mutt_
str_replace (&k->keyid, p);
+ str_replace (&k->keyid, p);
break;
}
break;
}
@@
-209,7
+213,7
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
char tstr[11];
struct tm time;
char tstr[11];
struct tm time;
- d
print (2, (debugfile,
"time stamp: %s\n", p));
+ d
ebug_print (2, (
"time stamp: %s\n", p));
if (!p)
break;
if (!p)
break;
@@
-240,11
+244,11
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))
break;
if (!is_uid && (*is_subkey && option (OPTPGPIGNORESUB)))
break;
- d
print (2, (debugfile,
"user ID: %s\n", p));
+ d
ebug_print (2, (
"user ID: %s\n", p));
- uid =
safe
_calloc (sizeof (pgp_uid_t), 1);
+ uid =
mem
_calloc (sizeof (pgp_uid_t), 1);
fix_uid (p);
fix_uid (p);
- uid->addr = s
afe_str
dup (p);
+ uid->addr = s
tr_
dup (p);
uid->trust = trust;
uid->flags |= flags;
uid->parent = k;
uid->trust = trust;
uid->flags |= flags;
uid->parent = k;
@@
-261,7
+265,7
@@
static pgp_key_t parse_pub_line (char *buf, int *is_subkey, pgp_key_t k)
case 11: /* signature class */
break;
case 12: /* key capabilities */
case 11: /* signature class */
break;
case 12: /* key capabilities */
- d
print (2, (debugfile,
"capabilities info: %s\n", p));
+ d
ebug_print (2, (
"capabilities info: %s\n", p));
while (*p) {
switch (*p++) {
while (*p) {
switch (*p++) {
@@
-306,7
+310,7
@@
pgp_key_t pgp_get_candidates (pgp_ring_t keyring, LIST * hints)
if ((devnull = open ("/dev/null", O_RDWR)) == -1)
return NULL;
if ((devnull = open ("/dev/null", O_RDWR)) == -1)
return NULL;
-
mutt_
str_replace (&_chs, Charset);
+ str_replace (&_chs, Charset);
thepid = pgp_invoke_list_keys (NULL, &fp, NULL, -1, -1, devnull,
keyring, hints);
thepid = pgp_invoke_list_keys (NULL, &fp, NULL, -1, -1, devnull,
keyring, hints);