changeset: 6613:a6a4d6ed0f19 user: Kevin McCarthy <ke...@8t8.us> date: Sun Apr 10 16:02:06 2016 -0700 link: http://dev.mutt.org/hg/mutt/rev/a6a4d6ed0f19
Fix mutt_protect() when INLINE is set. (closes #3828) The oppenc changes allow security bits to be set even when not encrypting or signing (for instance, OPPENCRYPT and INLINE). mutt_protect() assumed that if INLINE is set, then either ENCRYPT or SIGN must also be set. Specifically, it would end up inline-signing the message even though neither was set. Ensure mutt_protect() is a noop if neither SIGN or ENCRYPT are set. In ci_send_message(), check for sign or encrypt before calling the crypt_get_keys() / mutt_protect() block, and also in the fcc section (since clear_content would be NULL if not). The second change to the fcc part is somewhat redundant, but better to be explicit and avoid the case where the subtype is somehow "encrypted" or "signed" even though msg->security wasn't set thus. changeset: 6614:5464329344cd user: Kevin McCarthy <ke...@8t8.us> date: Sun Apr 10 18:30:21 2016 -0700 link: http://dev.mutt.org/hg/mutt/rev/5464329344cd merge stable diffs (205 lines): diff -r f7db9cefd3b0 -r 5464329344cd alias.c --- a/alias.c Tue Apr 05 14:31:36 2016 -0700 +++ b/alias.c Sun Apr 10 18:30:21 2016 -0700 @@ -423,6 +423,8 @@ { if (dry) return -1; + if (l == (size_t)(-1)) + memset (&mb, 0, sizeof (mbstate_t)); *dest++ = '_'; rv = -1; } diff -r f7db9cefd3b0 -r 5464329344cd crypt.c --- a/crypt.c Tue Apr 05 14:31:36 2016 -0700 +++ b/crypt.c Sun Apr 10 18:30:21 2016 -0700 @@ -137,6 +137,9 @@ if (!WithCrypto) return -1; + if (!(msg->security & (ENCRYPT | SIGN))) + return 0; + if ((msg->security & SIGN) && !crypt_valid_passphrase (msg->security)) return (-1); diff -r f7db9cefd3b0 -r 5464329344cd curs_lib.c --- a/curs_lib.c Tue Apr 05 14:31:36 2016 -0700 +++ b/curs_lib.c Sun Apr 10 18:30:21 2016 -0700 @@ -1034,6 +1034,8 @@ { if (k == (size_t)(-1) || k == (size_t)(-2)) { + if (k == (size_t)(-1)) + memset (&mbstate, 0, sizeof (mbstate)); k = (k == (size_t)(-1)) ? 1 : n; wc = replacement_char (); } diff -r f7db9cefd3b0 -r 5464329344cd help.c --- a/help.c Tue Apr 05 14:31:36 2016 -0700 +++ b/help.c Sun Apr 10 18:30:21 2016 -0700 @@ -103,6 +103,8 @@ { if (k == (size_t)(-1) || k == (size_t)(-2)) { + if (k == (size_t)(-1)) + memset (&mbstate1, 0, sizeof (mbstate1)); k = (k == (size_t)(-1)) ? 1 : len; wc = replacement_char (); } @@ -165,6 +167,8 @@ m = n; if (k == (size_t)(-1) || k == (size_t)(-2)) { + if (k == (size_t)(-1)) + memset (&mbstate, 0, sizeof (mbstate)); k = (k == (size_t)(-1)) ? 1 : len; wc = replacement_char (); } diff -r f7db9cefd3b0 -r 5464329344cd imap/browse.c --- a/imap/browse.c Tue Apr 05 14:31:36 2016 -0700 +++ b/imap/browse.c Sun Apr 10 18:30:21 2016 -0700 @@ -319,11 +319,9 @@ goto fail; } - /* TODO: add mutt_error call, such as - * "Cannot rename root folder" - */ if (!mx.mbox) { + mutt_error _("Cannot rename root folder"); goto fail; } diff -r f7db9cefd3b0 -r 5464329344cd pager.c --- a/pager.c Tue Apr 05 14:31:36 2016 -0700 +++ b/pager.c Sun Apr 10 18:30:21 2016 -0700 @@ -1011,10 +1011,14 @@ for (; len > 0; buf += k, len -= k) { k = mbrtowc (NULL, (char *) buf, len, &mbstate); - if (k == -2) + if (k == (size_t)(-2)) break; - else if (k == -1 || k == 0) + else if (k == (size_t)(-1) || k == 0) + { + if (k == (size_t)(-1)) + memset (&mbstate, 0, sizeof (mbstate)); k = 1; + } } *buf = '\0'; @@ -1092,7 +1096,8 @@ { int space = -1; /* index of the last space or TAB */ int col = option (OPTMARKERS) ? (*lineInfo)[n].continuation : 0; - int ch, vch, k, last_special = -1, special = 0, t; + size_t k; + int ch, vch, last_special = -1, special = 0, t; wchar_t wc; mbstate_t mbstate; int wrap_cols = mutt_term_width ((flags & M_PAGER_NOWRAP) ? 0 : Wrap); @@ -1123,8 +1128,10 @@ break; k = mbrtowc (&wc, (char *)buf+ch, cnt-ch, &mbstate); - if (k == -2 || k == -1) + if (k == (size_t)(-2) || k == (size_t)(-1)) { + if (k == (size_t)(-1)) + memset(&mbstate, 0, sizeof(mbstate)); dprint (1, (debugfile, "%s:%d: mbrtowc returned %d; errno = %d.\n", __FILE__, __LINE__, k, errno)); if (col + 4 > wrap_cols) @@ -1150,15 +1157,18 @@ { wchar_t wc1; mbstate_t mbstate1; - int k1, k2; + size_t k1, k2; - while ((wc1 = 0, mbstate1 = mbstate, - k1 = k + mbrtowc (&wc1, (char *)buf+ch+k, cnt-ch-k, &mbstate1), - k1 - k > 0 && wc1 == '\b') && - (wc1 = 0, - k2 = mbrtowc (&wc1, (char *)buf+ch+k1, cnt-ch-k1, &mbstate1), - k2 > 0 && IsWPrint (wc1))) + mbstate1 = mbstate; + k1 = mbrtowc (&wc1, (char *)buf+ch+k, cnt-ch-k, &mbstate1); + while ((k1 != (size_t)(-2)) && (k1 != (size_t)(-1)) && + (k1 > 0) && (wc1 == '\b')) { + k2 = mbrtowc (&wc1, (char *)buf+ch+k+k1, cnt-ch-k-k1, &mbstate1); + if ((k2 == (size_t)(-2)) || (k2 == (size_t)(-1)) || + (k2 == 0) || (!IsWPrint (wc1))) + break; + if (wc == wc1) { special |= (wc == '_' && special & A_UNDERLINE) @@ -1174,9 +1184,11 @@ /* special = 0; / * overstrike: nothing to do! */ wc = wc1; } - ch += k1; + + ch += k + k1; k = k2; mbstate = mbstate1; + k1 = mbrtowc (&wc1, (char *)buf+ch+k, cnt-ch-k, &mbstate1); } } diff -r f7db9cefd3b0 -r 5464329344cd rfc2047.c --- a/rfc2047.c Tue Apr 05 14:31:36 2016 -0700 +++ b/rfc2047.c Sun Apr 10 18:30:21 2016 -0700 @@ -410,7 +410,7 @@ int ret = 0; char *buf; size_t bufpos, buflen; - char *u, *t0, *t1, *t; + char *u = NULL, *t0, *t1, *t; char *s0, *s1; size_t ulen, r, n, wlen; encoder_t encoder; @@ -423,7 +423,7 @@ { ret = 1; icode = 0; - u = safe_malloc ((ulen = dlen) + 1); + safe_realloc (&u, (ulen = dlen) + 1); memcpy (u, d, dlen); u[ulen] = 0; } diff -r f7db9cefd3b0 -r 5464329344cd send.c --- a/send.c Tue Apr 05 14:31:36 2016 -0700 +++ b/send.c Sun Apr 10 18:30:21 2016 -0700 @@ -1717,7 +1717,7 @@ if (WithCrypto) { - if (msg->security) + if (msg->security & (ENCRYPT | SIGN)) { /* save the decrypted attachments */ clear_content = msg->content; @@ -1781,7 +1781,7 @@ BODY *save_sig = NULL; BODY *save_parts = NULL; - if (WithCrypto && msg->security && option (OPTFCCCLEAR)) + if (WithCrypto && (msg->security & (ENCRYPT | SIGN)) && option (OPTFCCCLEAR)) msg->content = clear_content; /* check to see if the user wants copies of all attachments */ @@ -1789,6 +1789,7 @@ msg->content->type == TYPEMULTIPART) { if (WithCrypto + && (msg->security & (ENCRYPT | SIGN)) && (mutt_strcmp (msg->content->subtype, "encrypted") == 0 || mutt_strcmp (msg->content->subtype, "signed") == 0)) {