Stefan Assmann [Tue, 30 May 2017 07:50:40 +0000 (09:50 +0200)]
include mutt_regex.h in globals.h
Error observered
In file included from main.c:40:0:
globals.h:56:20: error: storage size of 'AttachKeyword' isn't known
WHERE struct Regex AttachKeyword;
^~~~~~~~~~~~~
globals.h:288:20: error: storage size of 'PgpGoodSign' isn't known
WHERE struct Regex PgpGoodSign;
^~~~~~~~~~~
Adding header include for mutt_regex.h.
Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
Stefan Assmann [Tue, 30 May 2017 06:25:33 +0000 (08:25 +0200)]
check return value of fgets
Following warning was observed:
init.c: In function 'mutt_init':
mutt.h:53:15: warning: ignoring return value of 'fgets_unlocked', declared with attribute warn_unused_result [-Wunused-result]
#define fgets fgets_unlocked
init.c:4053:7: note: in expansion of macro 'fgets'
fgets(buffer, sizeof(buffer), f);
^~~~~
Added code that checks return value.
Signed-off-by: Stefan Assmann <sassmann@kpanic.de>
Richard Russon [Wed, 7 Jun 2017 21:56:59 +0000 (22:56 +0100)]
merge: upstream fixes (mutt/default)
* Fix "format string is not a string literal" warnings. (closes #3949)
* Enable TEXTDOMAINDIR override to make translation testing easier.
* Change km_dokey() to return -2 on a timeout/sigwinch.
* Fix tag-prefix to not abort on $timeout.
* Restore setenv function.
* Move setting of GPG_TTY to mutt_init(). (see #3948)
* Add a mutt_endwin() before invoking $sendmail. (closes #3948)
Kevin McCarthy [Wed, 7 Jun 2017 01:38:47 +0000 (18:38 -0700)]
Add a mutt_endwin() before invoking $sendmail. (closes #3948)
This is to support invoking a program such as msmtp that can use gpg
to decrypt a password. The ncurses pinentry can corrupt the screen
unless we exit curses.
Kevin McCarthy [Thu, 1 Jun 2017 22:17:01 +0000 (15:17 -0700)]
Change km_dokey() to return -2 on a timeout/sigwinch.
In some cases, such as tag-prefix or _mutt_enter_string(), it is
desirable to be able to distinguish between a timeout/sigwinch event
and an input error/abort/ctrl-g.
toogley [Mon, 5 Jun 2017 14:18:37 +0000 (16:18 +0200)]
github: simplify PR template
In a lot of PR's, either the question "Why is this PR needed" is removed
or answered very similar to "What does this PR do?". Therefore, i think
this can be removed.
Richard Russon [Thu, 1 Jun 2017 18:38:57 +0000 (19:38 +0100)]
merge: upstream fixes (mutt/default)
* Convert classic s/mime to space delimit findKeys output.
* Add self-encrypt options for PGP and S/MIME.
* Change $postpone_encrypt to use self-encrypt variables first.
* automatic post-release commit for mutt-1.8.3
* Add note about message scoring and thread patterns. (see #3947)
Kevin McCarthy [Wed, 31 May 2017 23:18:29 +0000 (16:18 -0700)]
Add note about message scoring and thread patterns. (see #3947)
Because scoring occurs before the mailbox is sorted, thread patterns
don't work. Document a suggested workaround of pushing the score
command in a folder hook.
Also, fix the link target for the score command synopsis.
Kevin McCarthy [Mon, 29 May 2017 18:48:43 +0000 (11:48 -0700)]
Change $postpone_encrypt to use self-encrypt variables first.
The concept of postpone encryption is similar to self-encrypting on
send. The problem is the $postpone_encrypt_as option doesn't take
into account whether PGP or S/MIME is being used.
Since we need to add the new options for self-encryption, modify
$postpone_encrypt to use them by default instead, falling back to
$postpone_encrypt_as if they are unset. Note $postpone_encrypt_as is
deprecated in the documentation.
$pgp_sign_as and $smime_default_key are inappropriate to use, as they
specify signing key/certs. In some cases, this is a different value
than the encryption key/cert.
Kevin McCarthy [Mon, 29 May 2017 18:48:41 +0000 (11:48 -0700)]
Convert classic s/mime to space delimit findKeys output.
Unlike gpgme and classic pgp, smime used a "cert\ncert\n" pattern.
Convert to use a space-delimited format, so the self-encrypt option
code can be uniform across pgp, s/mime, and gpgme.
Kevin McCarthy [Wed, 31 May 2017 23:18:29 +0000 (16:18 -0700)]
Add note about message scoring and thread patterns. (see #3947)
Because scoring occurs before the mailbox is sorted, thread patterns
don't work. Document a suggested workaround of pushing the score
command in a folder hook.
Also, fix the link target for the score command synopsis.
Richard Russon [Thu, 25 May 2017 23:28:30 +0000 (00:28 +0100)]
merge: upstream fixes (mutt/default)
* Move the IMAP msn field to IMAP_HEADER_DATA. (see #3942)
* Fix imap expunge to match msn and fix index. (see #3942)
* Fix cmd_parse_fetch() to match against MSN. (see #3942)
* Start fixing imap_read_headers() to account for MSN gaps. (see #3942)
* Add msn_index and max_msn to find and check boundaries by MSN. (see #3942)
* Properly adjust fetch ranges when handling new mail. (see #3942)
* Small imap fetch fixes. (see #3942)
* Don't abort header cache evaluation when there is a hole. (see #3942)
* Fix mfc overflow check and uninitialized variable.
* Fix potential segv if mx_open_mailbox is passed an empty string. (closes #3945)
* Don't clean up idata when closing an open-append mailbox.
* Don't clean up msn idata when closing an open-append mailbox. (see #3942)
* Fix memory leak when closing mailbox and using the sidebar.
* Change imap body cache cleanup to use the uid_hash.
Kevin McCarthy [Tue, 23 May 2017 22:53:30 +0000 (15:53 -0700)]
Fix memory leak when closing mailbox and using the sidebar.
The code updating the sidebar counts decremented the msgcount, but did
not set it back to the original value. Which means fastclose was not
freeing all the headers.
Update the sidebar only when something is deleted, since I don't
believe it's required otherwise and the code is a bit cleaner that
way.
Kevin McCarthy [Mon, 22 May 2017 11:43:24 +0000 (04:43 -0700)]
Fix mfc overflow check and uninitialized variable.
The check borrowed from mx_alloc_memory() works because it is
incremented 25 at a time. I don't believe it will work for the direct
set case used in imap_alloc_msn_index(). Instead, use a more
conservative check.
In imap_read_headers(), make sure mfhrc is initialized. It would be
tested without being set if imap_cmd_step() returned OK right away.
Kevin McCarthy [Mon, 22 May 2017 01:45:08 +0000 (18:45 -0700)]
Small imap fetch fixes. (see #3942)
Add an integer overflow test, pulled from mx_alloc_memory(), since the
count comes from a potentially hostile server.
After reviewing the RFC a bit, it turns out the server is not supposed
to send EXPUNGE responses during a FETCH. Change the comment, but
keep the conservative code.
Kevin McCarthy [Sun, 21 May 2017 17:51:38 +0000 (10:51 -0700)]
Properly adjust fetch ranges when handling new mail. (see #3942)
When pulling down headers, it is possible for expunge responses to
happen too. If we get a new mail count, we need to take into account
changes to the max_msn due to the expunges.
Kevin McCarthy [Sun, 21 May 2017 01:52:18 +0000 (18:52 -0700)]
Add msn_index and max_msn to find and check boundaries by MSN. (see #3942)
Since there can be gaps in MSNs, the largest MSN in the context is not
necessarily ctx->msgcount.
Use max_msn instead of ctx->msgcount for:
- the starting MSN of new mail header fetching
- boundary checking in fetch, expunge, and other places
Use msn_index to efficiently look up headers by MSN. This makes the
expunge code slightly more efficient. It also makes FETCH handling, and
duplicate FETCH FLAG handling efficient.
Kevin McCarthy [Sun, 21 May 2017 01:52:16 +0000 (18:52 -0700)]
Start fixing imap_read_headers() to account for MSN gaps. (see #3942)
Change the parameters to pass MSN instead of index, to make a bit
simpler.
Change header cache evaluation to look at the largest MSN retrieved
instead of ctx->msgcount for the next fetch start point. This still
depends on the assumption that MSNs are retrieved in ascending order,
which needs to be fixed.
Simplify the header cache inner loop termination and memory cleanup
logic. Fix a memory leak if a hole in the header cache occured.
Fix the header retrieval logic to take into account MSN gaps in the
results. Loop only as long as we get IMAP_CMD_CONTINUE instead of
over a fixed count. Simplify the inner loop termination and memory
cleanup logic too.
Simplify the "new mail while fetching" logic by creating a third outer
loop to handle re-fetches.
Fix msg_fetch_header() to return -2 if msg_parse_fetch() encounters a
corrupt FETCH response. Previously it would pass on the rc of
msg_parse_fetch(), meaning it would return -1 even though the response
was corrupt.
Kevin McCarthy [Sun, 21 May 2017 01:52:13 +0000 (18:52 -0700)]
Fix imap expunge to match msn and fix index. (see #3942)
The expunge needs to match against the MSN now. Since
cmd_parse_expunge() does not automatically fix h->index anymore,
change imap_expunge_mailbox() to fix up the h->index values.
Kevin McCarthy [Sun, 21 May 2017 01:52:12 +0000 (18:52 -0700)]
Move the IMAP msn field to IMAP_HEADER_DATA. (see #3942)
Ticket 3942 revealed that it is possible for a FETCH to have gaps in
the MSN numbers of the results. The code makes many assumptions that
equate context index counts and MSN. This is the first in a series of
commits fixing that assumption.
The header->index field is supposed to hold the SORT_ORDER index
number of the message. If there are gaps in the MSN, than the highext
MSN can in fact be out of the range 0..ctx->msgcount-1.
After studying the code, I believe curs_main.c would actually work
with header->index values out of the range, at least for IMAP. But
some other parts of the code, such as mutt_reopen_mailbox(), do rely
on the values being a valid index to ctx->hdrs[]. And the
intertwining of menu->oldcurrent with header->index values makes me
nervous about future changes.
So, to be safe, move the MSN to its own field in IMAP_HEADER_DATA.
Kevin McCarthy [Tue, 23 May 2017 22:53:30 +0000 (15:53 -0700)]
Fix memory leak when closing mailbox and using the sidebar.
The code updating the sidebar counts decremented the msgcount, but did
not set it back to the original value. Which means fastclose was not
freeing all the headers.
Update the sidebar only when something is deleted, since I don't
believe it's required otherwise and the code is a bit cleaner that
way.
Richard Russon [Sat, 20 May 2017 14:05:34 +0000 (15:05 +0100)]
add names prototype arguments
Header files are easier to understand if the arguments are named.
e.g., replace:
int mutt_copy_stream(FILE *, FILE *);
with:
int mutt_copy_stream(FILE *fin, FILE *fout);