X-Git-Url: http://git.madism.org/?a=blobdiff_plain;f=pgppubring.c;h=9f2ee46d9818264e411f2aec8daa2096445b910f;hb=8e037c67a88cb4680c4391134c578e3b55a80f8a;hp=159a9d5dccd0d6037eb0535fbdf5fa75412f2042;hpb=ba5e3af4ea19e1d20c80941c077039871ec84258;p=apps%2Fmadmutt.git diff --git a/pgppubring.c b/pgppubring.c index 159a9d5..9f2ee46 100644 --- a/pgppubring.c +++ b/pgppubring.c @@ -26,6 +26,8 @@ # include "config.h" #endif +#include + #include "lib/mem.h" #include "lib/str.h" @@ -36,13 +38,13 @@ #include #ifdef HAVE_GETOPT_H # include -#endif -#include - +#else extern char *optarg; extern int optind; +#endif +#include -short Umask; /* dirty hack because we need Umask in lib.c but don't want globals.h there */ +short Umask; /* dirty hack because we need Umask in lib.c but don't want globals.h there */ #include "sha1.h" #include "md5.h" @@ -56,8 +58,8 @@ short Umask; /* dirty hack because we need Umask in lib.c but #define FGETPOS(fp,pos) fgetpos((fp),&(pos)) #define FSETPOS(fp,pos) fsetpos((fp),&(pos)) #else -#define FGETPOS(fp,pos) pos=ftell((fp)); -#define FSETPOS(fp,pos) fseek((fp),(pos),SEEK_SET) +#define FGETPOS(fp,pos) pos=ftello((fp)); +#define FSETPOS(fp,pos) fseeko((fp),(pos),SEEK_SET) #endif @@ -252,7 +254,7 @@ static pgp_key_t pgp_parse_pgp2_key (unsigned char *buff, size_t l) bailout: - mem_free (&p); + p_delete(&p); return NULL; } @@ -579,7 +581,7 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp) #ifdef HAVE_FGETPOS fpos_t pos; #else - long pos; + off_t pos; #endif pgp_key_t root = NULL; @@ -667,10 +669,7 @@ static pgp_key_t pgp_parse_keyblock (FILE * fp) if (!addr) break; - chr = mem_malloc (l); - memcpy (chr, buff + 1, l - 1); - chr[l - 1] = '\0'; - + chr = p_dupstr(buff + 1, l - 1); *addr = uid = mem_calloc (1, sizeof (pgp_uid_t)); /* XXX */ uid->addr = chr; @@ -730,7 +729,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], #ifdef HAVE_FGETPOS fpos_t pos, keypos; #else - long pos, keypos; + off_t pos, keypos; #endif unsigned char *buff = NULL; @@ -744,10 +743,10 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], size_t error_buf_len; error_buf_len = sizeof ("fopen: ") - 1 + str_len (ringfile) + 1; - error_buf = mem_malloc (error_buf_len); + error_buf = p_new(char, error_buf_len); snprintf (error_buf, error_buf_len, "fopen: %s", ringfile); perror (error_buf); - mem_free (&error_buf); + p_delete(&error_buf); return; } @@ -764,10 +763,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], keypos = pos; } else if (pt == PT_NAME) { - char *tmp = mem_malloc (l); - - memcpy (tmp, buff + 1, l - 1); - tmp[l - 1] = '\0'; + char *tmp = p_dupstr(buff + 1, l - 1); /* mutt_decode_utf8_string (tmp, chs); */ @@ -785,7 +781,7 @@ static void pgpring_find_candidates (char *ringfile, const char *hints[], pgp_free_key (&p); } - mem_free (&tmp); + p_delete(&tmp); } FGETPOS (rfp, pos);