X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=lib-crypt%2Fpgpmicalg.c;h=ae16b11a4d7472c2bf326790038358f07b48c507;hb=3f35b8874fb10587ce43e2853a1ef95573222015;hp=1c322be064d206c878357b0f49dd69aa23d135c4;hpb=4761fa78a6dfc9437caa6e6e0aac806e50e01c83;p=apps%2Fmadmutt.git diff --git a/lib-crypt/pgpmicalg.c b/lib-crypt/pgpmicalg.c index 1c322be..ae16b11 100644 --- a/lib-crypt/pgpmicalg.c +++ b/lib-crypt/pgpmicalg.c @@ -11,26 +11,16 @@ * algorithm. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif +#include + +#include +#include -#include "mutt.h" #include "handler.h" #include "pgp.h" #include "pgppacket.h" #include "charset.h" -#include -#include -#include -#include - -#include - -#include - -#include "lib/debug.h" static struct { short id; @@ -75,11 +65,10 @@ static void pgp_dearmor (FILE * in, FILE * out) /* find the beginning of ASCII armor */ while ((r = fgets (line, sizeof (line), in)) != NULL) { - if (!strncmp (line, "-----BEGIN", 10)) + if (!m_strncmp (line, "-----BEGIN", 10)) break; } if (r == NULL) { - debug_print (1, ("Can't find begin of ASCII armor.\n")); return; } @@ -91,7 +80,6 @@ static void pgp_dearmor (FILE * in, FILE * out) break; } if (r == NULL) { - debug_print (1, ("Armor header doesn't end.\n")); return; } @@ -101,32 +89,28 @@ static void pgp_dearmor (FILE * in, FILE * out) /* find the checksum */ while ((r = fgets (line, sizeof (line), in)) != NULL) { - if (*line == '=' || !strncmp (line, "-----END", 8)) + if (*line == '=' || !m_strncmp (line, "-----END", 8)) break; } if (r == NULL) { - debug_print (1, ("Can't find end of ASCII armor.\n")); return; } if ((end = ftello (in) - m_strlen(line)) < start) { - debug_print (1, ("end < start???\n")); return; } if (fseeko (in, start, SEEK_SET) == -1) { - debug_print (1, ("Can't seekto start.\n")); return; } - mutt_decode_base64 (&state, end - start, 0, (iconv_t) - 1); + mutt_decode_base64 (&state, end - start, 0, MUTT_ICONV_ERROR); } static short pgp_mic_from_packet (unsigned char *p, size_t len) { /* is signature? */ if ((p[0] & 0x3f) != PT_SIG) { - debug_print (1, ("tag = %d, want %d.\n", p[0] & 0x3f, PT_SIG)); return -1; } @@ -137,7 +121,6 @@ static short pgp_mic_from_packet (unsigned char *p, size_t len) /* version 4 signature */ return (short) p[4]; else { - debug_print (1, ("Bad signature packet.\n")); return -1; } } @@ -154,15 +137,15 @@ static short pgp_find_hash (const char *fname) short rv = -1; - mutt_mktemp (tempfile); - if ((out = safe_fopen (tempfile, "w+")) == NULL) { - mutt_perror (tempfile); + out = m_tempfile (tempfile, sizeof(tempfile), NONULL(Tempdir), NULL); + if (!out) { + mutt_perror (_("Can't create temporary file")); goto bye; } unlink (tempfile); if ((in = fopen (fname, "r")) == NULL) { - mutt_perror (fname); + mutt_perror (_("Can't create temporary file")); goto bye; } @@ -172,14 +155,11 @@ static short pgp_find_hash (const char *fname) if ((p = pgp_read_packet (out, &l)) != NULL) { rv = pgp_mic_from_packet (p, l); } - else { - debug_print (1, ("No packet.\n")); - } bye: - safe_fclose (&in); - safe_fclose (&out); + m_fclose(&in); + m_fclose(&out); pgp_release_packet (); return rv; }