X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=crypt.c;h=923b8d759b63b84a020b269002fde0caa9a81f19;hp=39fead1175784853c0b95282111d80deb913d41f;hb=ee869a42bc5677da8e3602ec1947af1736786648;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/crypt.c b/crypt.c index 39fead1..923b8d7 100644 --- a/crypt.c +++ b/crypt.c @@ -1,4 +1,5 @@ /* + * Copyright notice from original mutt: * Copyright (C) 1996,1997 Michael R. Elkins * Copyright (C) 1999-2000 Thomas Roessler * Copyright (C) 2001 Thomas Roessler @@ -6,32 +7,30 @@ * Copyright (C) 2003 Werner Koch * Copyright (C) 2004 g10code GmbH * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. + * This file is part of mutt-ng, see http://www.muttng.org/. + * It's licensed under the GNU General Public License, + * please see the file GPL in the top level source directory. */ #if HAVE_CONFIG_H # include "config.h" #endif +#include +#include +#include +#include +#include + #include "mutt.h" +#include "handler.h" #include "mutt_curses.h" #include "mime.h" #include "copy.h" #include "mutt_crypt.h" #include "pgp.h" + #include #include #include @@ -54,7 +53,7 @@ /* print the current time to avoid spoofing of the signature output */ -void crypt_current_time (STATE * s, char *app_name) +void crypt_current_time (STATE * s, const char *app_name) { time_t t; char p[STRING], tmp[STRING]; @@ -391,7 +390,7 @@ int mutt_is_application_smime (BODY * m) /* no .p7c, .p10 support yet. */ - len = mutt_strlen (t) - 4; + len = m_strlen(t) - 4; if (len > 0 && *(t + len) == '.') { len++; if (!ascii_strcasecmp ((t + len), "p7m")) @@ -490,7 +489,7 @@ int crypt_write_signed (BODY * a, STATE * s, const char *tempfile) return -1; } - fseek (s->fpin, a->hdr_offset, 0); + fseeko (s->fpin, a->hdr_offset, 0); bytes = a->length + a->offset - a->hdr_offset; hadcr = 0; while (bytes > 0) { @@ -533,7 +532,7 @@ void convert_to_7bit (BODY * a) convert_to_7bit (a->parts); } else if (a->type == TYPEMESSAGE && - mutt_strcasecmp (a->subtype, "delivery-status")) { + str_casecmp (a->subtype, "delivery-status")) { if (a->encoding != ENC7BIT) mutt_message_to_7bit (a, NULL); } @@ -700,7 +699,7 @@ int crypt_get_keys (HEADER * msg, char **keylist) -static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n) +static void crypt_fetch_signatures (BODY ***signatures, BODY * a, int *n) { if (!WithCrypto) return; @@ -710,7 +709,7 @@ static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n) crypt_fetch_signatures (signatures, a->parts, n); else { if ((*n % 5) == 0) - safe_realloc (signatures, (*n + 6) * sizeof (BODY **)); + p_realloc(signatures, *n + 6); (*signatures)[(*n)++] = a; } @@ -722,7 +721,7 @@ static void crypt_fetch_signatures (BODY *** signatures, BODY * a, int *n) * This routine verifies a "multipart/signed" body. */ -void mutt_signed_handler (BODY * a, STATE * s) +int mutt_signed_handler (BODY * a, STATE * s) { char tempfile[_POSIX_PATH_MAX]; char *protocol; @@ -734,9 +733,10 @@ void mutt_signed_handler (BODY * a, STATE * s) int sigcnt = 0; int i; short goodsig = 1; + int rc = 0; if (!WithCrypto) - return; + return (-1); protocol = mutt_get_parameter ("protocol", a->parameter); a = a->parts; @@ -760,30 +760,28 @@ void mutt_signed_handler (BODY * a, STATE * s) /* consistency check */ if (!(a && a->next && a->next->type == protocol_major && - !mutt_strcasecmp (a->next->subtype, protocol_minor))) { + !str_casecmp (a->next->subtype, protocol_minor))) { state_attach_puts (_("[-- Error: " "Inconsistent multipart/signed structure! --]\n\n"), s); - mutt_body_handler (a, s); - return; + return mutt_body_handler (a, s); } if ((WithCrypto & APPLICATION_PGP) && protocol_major == TYPEAPPLICATION - && !mutt_strcasecmp (protocol_minor, "pgp-signature")); + && !str_casecmp (protocol_minor, "pgp-signature")); else if ((WithCrypto & APPLICATION_SMIME) && protocol_major == TYPEAPPLICATION - && !(mutt_strcasecmp (protocol_minor, "x-pkcs7-signature") - && mutt_strcasecmp (protocol_minor, "pkcs7-signature"))); + && !(str_casecmp (protocol_minor, "x-pkcs7-signature") + && str_casecmp (protocol_minor, "pkcs7-signature"))); else if (protocol_major == TYPEMULTIPART - && !mutt_strcasecmp (protocol_minor, "mixed")); + && !str_casecmp (protocol_minor, "mixed")); else { state_printf (s, _("[-- Error: " "Unknown multipart/signed protocol %s! --]\n\n"), protocol); - mutt_body_handler (a, s); - return; + return mutt_body_handler (a, s); } if (s->flags & M_DISPLAY) { @@ -796,7 +794,7 @@ void mutt_signed_handler (BODY * a, STATE * s) for (i = 0; i < sigcnt; i++) { if ((WithCrypto & APPLICATION_PGP) && signatures[i]->type == TYPEAPPLICATION - && !mutt_strcasecmp (signatures[i]->subtype, "pgp-signature")) { + && !str_casecmp (signatures[i]->subtype, "pgp-signature")) { if (crypt_pgp_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; @@ -806,8 +804,8 @@ void mutt_signed_handler (BODY * a, STATE * s) if ((WithCrypto & APPLICATION_SMIME) && signatures[i]->type == TYPEAPPLICATION && - (!mutt_strcasecmp (signatures[i]->subtype, "x-pkcs7-signature") - || !mutt_strcasecmp (signatures[i]->subtype, + (!str_casecmp (signatures[i]->subtype, "x-pkcs7-signature") + || !str_casecmp (signatures[i]->subtype, "pkcs7-signature"))) { if (crypt_smime_verify_one (signatures[i], s, tempfile) != 0) goodsig = 0; @@ -830,15 +828,17 @@ void mutt_signed_handler (BODY * a, STATE * s) state_attach_puts (_("[-- The following data is signed --]\n\n"), s); - FREE (&signatures); + p_delete(&signatures); } else state_attach_puts (_("[-- Warning: Can't find any signatures. --]\n\n"), s); } - mutt_body_handler (a, s); + rc = mutt_body_handler (a, s); if (s->flags & M_DISPLAY && sigcnt) state_attach_puts (_("\n[-- End of signed data --]\n"), s); + + return (rc); }