X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=smime.c;h=6928585428a0f1332ffd5b976c4b47afc8aec39e;hp=1f2522232713ee7cadafec885405e7b1c3117672;hb=50159c7895acc32e014ca5832e461f05c3d98fe3;hpb=df70e07e24add1869bcc9b7af2277d9d0c09a281 diff --git a/smime.c b/smime.c index 1f25222..6928585 100644 --- a/smime.c +++ b/smime.c @@ -1,21 +1,12 @@ /* + * Copyright notice from original mutt: * Copyright (C) 2001,2002 Oliver Ehli * Copyright (C) 2002 Mike Schiraldi * Copyright (C) 2004 g10 Code 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 @@ -29,6 +20,11 @@ #include "mime.h" #include "copy.h" +#include "lib/mem.h" +#include "lib/intl.h" +#include "lib/str.h" +#include "lib/debug.h" + #include #include #include @@ -254,12 +250,9 @@ static void mutt_smime_command (char *d, size_t dlen, { mutt_FormatString (d, dlen, NONULL (fmt), _mutt_fmt_smime_command, (unsigned long) cctx, 0); - dprint (2, (debugfile, "mutt_smime_command: %s\n", d)); + debug_print (2, ("%s\n", d)); } - - - static pid_t smime_invoke (FILE ** smimein, FILE ** smimeout, FILE ** smimeerr, int smimeinfd, int smimeoutfd, int smimeerrfd, const char *fname, @@ -408,7 +401,7 @@ char *smime_ask_for_key (char *prompt, char *mailbox, short public) continue; /* Check if query matches this certificate */ - if (!mutt_stristr (fields[0], qry) && !mutt_stristr (fields[2], qry)) + if (!str_isstr (fields[0], qry) && !str_isstr (fields[2], qry)) continue; Table[cur].hash = hash; @@ -493,8 +486,8 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, if (!mailbox && !query) return (NULL); - addr_len = mailbox ? mutt_strlen (mailbox) : 0; - query_len = query ? mutt_strlen (query) : 0; + addr_len = mailbox ? safe_strlen (mailbox) : 0; + query_len = query ? safe_strlen (query) : 0; *key = '\0'; @@ -516,7 +509,7 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, } while (fgets (buf, sizeof (buf) - 1, fp) != NULL) - if (mailbox && !(mutt_strncasecmp (mailbox, buf, addr_len))) { + if (mailbox && !(safe_strncasecmp (mailbox, buf, addr_len))) { numFields = sscanf (buf, MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " MUTT_FORMAT (STRING) " " @@ -578,13 +571,13 @@ char *smime_get_field_from_db (char *mailbox, char *query, short public, /* query = label: return certificate. */ if (numFields >= 3 && - !(mutt_strncasecmp (query, fields[2], query_len))) { + !(safe_strncasecmp (query, fields[2], query_len))) { ask = 0; strfcpy (key, fields[1], sizeof (key)); } /* query = certificate: return intermediate certificate. */ else if (numFields >= 4 && - !(mutt_strncasecmp (query, fields[1], query_len))) { + !(safe_strncasecmp (query, fields[1], query_len))) { ask = 0; strfcpy (key, fields[3], sizeof (key)); } @@ -653,7 +646,7 @@ void _smime_getkeys (char *mailbox) if (k) { /* the key used last time. */ if (*SmimeKeyToUse && - !mutt_strcasecmp (k, SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1)) { + !safe_strcasecmp (k, SmimeKeyToUse + safe_strlen (SmimeKeys) + 1)) { FREE (&k); return; } @@ -666,7 +659,7 @@ void _smime_getkeys (char *mailbox) snprintf (SmimeCertToUse, sizeof (SmimeCertToUse), "%s/%s", NONULL (SmimeCertificates), k); - if (mutt_strcasecmp (k, SmimeDefaultKey)) + if (safe_strcasecmp (k, SmimeDefaultKey)) smime_void_passphrase (); FREE (&k); @@ -674,8 +667,8 @@ void _smime_getkeys (char *mailbox) } if (*SmimeKeyToUse) { - if (!mutt_strcasecmp (SmimeDefaultKey, - SmimeKeyToUse + mutt_strlen (SmimeKeys) + 1)) + if (!safe_strcasecmp (SmimeDefaultKey, + SmimeKeyToUse + safe_strlen (SmimeKeys) + 1)) return; smime_void_passphrase (); @@ -777,10 +770,10 @@ char *smime_findKeys (ADDRESS * to, ADDRESS * cc, ADDRESS * bcc) return NULL; } - keylist_size += mutt_strlen (keyID) + 2; + keylist_size += safe_strlen (keyID) + 2; safe_realloc (&keylist, keylist_size); sprintf (keylist + keylist_used, "%s\n", keyID); /* __SPRINTF_CHECKED__ */ - keylist_used = mutt_strlen (keylist); + keylist_used = safe_strlen (keylist); rfc822_free_address (&addr); @@ -837,8 +830,8 @@ static int smime_handle_cert_email (char *certificate, char *mailbox, while ((fgets (email, sizeof (email), fpout))) { - *(email + mutt_strlen (email) - 1) = '\0'; - if (mutt_strncasecmp (email, mailbox, mutt_strlen (mailbox)) == 0) + *(email + safe_strlen (email) - 1) = '\0'; + if (safe_strncasecmp (email, mailbox, safe_strlen (mailbox)) == 0) ret = 1; ret = ret < 0 ? 0 : ret; @@ -864,9 +857,9 @@ static int smime_handle_cert_email (char *certificate, char *mailbox, rewind (fpout); while ((fgets (email, sizeof (email), fpout))) { - *(email + mutt_strlen (email) - 1) = '\0'; - (*buffer)[count] = safe_calloc (1, mutt_strlen (email) + 1); - strncpy ((*buffer)[count], email, mutt_strlen (email)); + *(email + safe_strlen (email) - 1) = '\0'; + (*buffer)[count] = safe_calloc (1, safe_strlen (email) + 1); + strncpy ((*buffer)[count], email, safe_strlen (email)); count++; } } @@ -1246,7 +1239,7 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist) *certfile = '\0'; while (1) { - int off = mutt_strlen (certfile); + int off = safe_strlen (certfile); while (*++cert_end && *cert_end != '\n'); if (!*cert_end) @@ -1380,7 +1373,7 @@ BODY *smime_sign_message (BODY * a) if ((thepid = smime_invoke_sign (&smimein, NULL, &smimeerr, -1, fileno (smimeout), -1, filetosign)) == -1) { - mutt_perror _("Can't open OpenSSL subprocess!"); + mutt_perror (_("Can't open OpenSSL subprocess!")); fclose (smimeout); mutt_unlink (signedfile); @@ -1569,7 +1562,7 @@ int smime_verify_one (BODY * sigbdy, STATE * s, const char *tempfile) rewind (smimeerr); line = mutt_read_line (line, &linelen, smimeerr, &lineno); - if (linelen && !mutt_strcasecmp (line, "verification successful")) + if (linelen && !safe_strcasecmp (line, "verification successful")) badsig = 0; FREE (&line); @@ -1734,7 +1727,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile) } } while (fgets (buf, sizeof (buf) - 1, smimeout) != NULL) { - len = mutt_strlen (buf); + len = safe_strlen (buf); if (len > 1 && buf[len - 2] == '\r') { buf[len - 2] = '\n'; buf[len - 1] = '\0'; @@ -1785,7 +1778,7 @@ static BODY *smime_handle_entity (BODY * m, STATE * s, FILE * outFile) rewind (smimeerr); line = mutt_read_line (line, &linelen, smimeerr, &lineno); - if (linelen && !mutt_strcasecmp (line, "verification successful")) + if (linelen && !safe_strcasecmp (line, "verification successful")) m->goodsig = 1; FREE (&line); } @@ -1889,19 +1882,19 @@ int smime_send_menu (HEADER * msg, int *redraw) " 4: RC2-64, 5: RC2-128, or (f)orget it? "), _("12345f"))) { case 1: - mutt_str_replace (&SmimeCryptAlg, "des"); + str_replace (&SmimeCryptAlg, "des"); break; case 2: - mutt_str_replace (&SmimeCryptAlg, "des3"); + str_replace (&SmimeCryptAlg, "des3"); break; case 3: - mutt_str_replace (&SmimeCryptAlg, "rc2-40"); + str_replace (&SmimeCryptAlg, "rc2-40"); break; case 4: - mutt_str_replace (&SmimeCryptAlg, "rc2-64"); + str_replace (&SmimeCryptAlg, "rc2-64"); break; case 5: - mutt_str_replace (&SmimeCryptAlg, "rc2-128"); + str_replace (&SmimeCryptAlg, "rc2-128"); break; case 6: /* forget it */ break; @@ -1922,8 +1915,8 @@ int smime_send_menu (HEADER * msg, int *redraw) case 4: /* sign (a)s */ if ((p = smime_ask_for_key (_("Sign as: "), NULL, 0))) { - p[mutt_strlen (p) - 1] = '\0'; - mutt_str_replace (&SmimeDefaultKey, p); + p[safe_strlen (p) - 1] = '\0'; + str_replace (&SmimeDefaultKey, p); msg->security |= SIGN;