Kevin McCarthy [Sat, 14 Apr 2018 03:39:35 +0000 (20:39 -0700)]
Improve gss debug printing of status_string.
Commit f52ee2f7 ensured the debug strings were properly '\0'
terminated. However, it did not prevent the strncpy from reading past
the end of the status_string.value data; it simply capped it
afterwards. Improve the code so it only reads up to
status_string.length without overwriting the buffer.
Kevin McCarthy [Sat, 14 Apr 2018 02:03:29 +0000 (19:03 -0700)]
Remove trailing null count from gss_buffer_desc.length field.
RFC 2744 section 3.2.2 clearly states that trailing NULL characters
are not to be included in the length field, and are not to be assumed
to be present in the value field.
Thanks to Greg Hudson, who recently debugged this same issue with
fetchmail, and kindly took the time to look at Mutt's code too.
Kevin McCarthy [Sun, 8 Apr 2018 22:37:09 +0000 (15:37 -0700)]
Rename _regex.h to _mutt_regex.h to avoid name collision on Macs.
On Macs, <regex.h> includes <_regex.h>. Because Mutt defines '-I .'
during compilation, our bundled version of _regex.h was being used
instead of the system one.
I have no idea how it managed to work before, but starting in Xcode
9.3, the differences in struct size and fields started to produce a
crash and other strange behavior.
The real issue is our use of '-I .' during compilation, which allows
our local headers to override system ones. An easier fix for now is
to rename the header.
Many thanks to Charles Diza, Christian Ebert, and Fabian Groffen for
their help trying things out and helping to debug the problem.
Also, a huge thanks to Steve Karmeinsky for allowing me to ssh in to
his Mac so I could track down the underlying issue.
Kevin McCarthy [Mon, 2 Apr 2018 18:30:31 +0000 (11:30 -0700)]
configure: check for tinfo matching ncurses
When we selected ncursesw, look for tinfow as well. Since ncurses-6.1
the binary compatibility between tinfo and tinfow disappeared, resulting
in crashes and other odd behaviour.
This change checks for tinfo or tinfow based on which ncurses we found
to continue with.
https://bugs.gentoo.org/651552
[Thanks to Fabian Groffen for the patch. I made a minor modification
to fall back to tinfo because pre-6.1 systems may not have a tinfow
but still need tinfo to compile.]
Kevin McCarthy [Thu, 22 Mar 2018 16:32:31 +0000 (09:32 -0700)]
Fix s/mime non-detached signature handling.
This fix is based on stbuehler's patch from
https://dev.gnupg.org/T2919.
Recent versions of gpgme seem to terminate the connection for a
protocol error. stbuehler's analysis is that this is actually a
gpgme bug, but recreating the context works around the problem.
Kevin McCarthy [Thu, 22 Feb 2018 02:25:37 +0000 (18:25 -0800)]
Fix is_from() year parsing to abort on year overflow.
Unlike mutt_parse_date(), is_from() was not checking for overflow, and
could end up passing a negative year to mutt_mktime().
It should perhaps be changed to use mutt_atoi(), which does better
range checking, but that requires mutt_atoi() being changed to allow
trailing characters and its callers return value checks being
updated. I'll put that on the todo list.
Kevin McCarthy [Thu, 22 Feb 2018 02:18:53 +0000 (18:18 -0800)]
Cap parsed years at 9999 when converting to time_t.
Large year values, even those less than INT_MAX, apparently can cause
gmtime() and localtime() to return NULL. Mutt needs larger changes
checking and handling those errors, but this will prevent the
immediately triggerable issue.
Kevin McCarthy [Thu, 1 Feb 2018 19:10:01 +0000 (11:10 -0800)]
Add stub flea and muttbug scripts back.
It was rightfully pointed out that the removal was too abrupt. These
programs have been around for a long time, and many internet searches
still say to use them for reporting bugs.
Add stub versions which inform to use the gitlab url instead.
Kevin McCarthy [Sat, 6 Jan 2018 23:55:17 +0000 (15:55 -0800)]
Change imap literal counts to parse and store unsigned ints.
IMAP literals are of type number. Change imap_get_literal_count() to
use mutt_atoui() instead of atoi(). Change the return type variables
used to store the count to type unsigned int.
It's doubtful this was a real issue, but as long as we're cleaning up
incorrect atoi() usage, we should fix this too.
Kevin McCarthy [Sat, 6 Jan 2018 04:39:50 +0000 (20:39 -0800)]
Fix improper signed int conversion of IMAP uid and msn values.
Several places in the imap code, when parsing "number" and "nz-number"
values from the IMAP data, use atoi() and strtol(). This is
incorrect, and can result in failures when a uid value happens to be
larger than 2^31.
Create a helper function, mutt_atoui() and use that instead. One
place was using strtol() and relying on the endptr parameter, and so
was changed to use strtoul() instead.
Thanks to Paul Saunders for the bug report and original patch, which
this commit is based on.
Kevin McCarthy [Mon, 18 Dec 2017 20:55:20 +0000 (12:55 -0800)]
Determine latest tag using git describe.
Commit 8648db83 relies on `sort -V` which is unavailable on some
platforms. Instead just use `git describe` with --abbrev=0 to only
output the tag. We still manually compute the distance to avoid the
problem mentioned in that commit.
Additionally, add Vincent's fix from commit 3b142cea to the stable
branch.
Commit c1bcf4ba exposed a bug in the s/mime encryption code. It was
errorneously calling unlink on the list of generated cert files to
use.
Prior to that commit, the list had an initial space, which apparently
made the unlink fail. After that commit, encrypting to a single
certificate would end up deleting the certificate.
Remove the calls to unlink the cert file. Add some missing cleanup if
the call to openssl fails.
Aaron Schrab [Tue, 12 Dec 2017 02:46:30 +0000 (21:46 -0500)]
Change version.sh to manually compute version and distance.
In some cases `git describe` gives bizarre results (see URL below),
instead get the highest version-numbered tag contained in HEAD then
count the number of commits that aren't included in it.
Kevin McCarthy [Wed, 27 Sep 2017 02:44:11 +0000 (19:44 -0700)]
Fix uses of context->changed as a counter.
The first was in mx_update_tables(), but only when "not committing".
This is used by mh/maildir during an "occult" update, and in imap when
expunging the mailbox. It meant to simply turn on changed when a
single changed header is seen.
The second use was in imap_sync_message_for_copy(). Previously this
was used for a server side copy/save, but is now also used for
fast-trash copying. Remove the code that was trying to decrement the
counter: this function is not capable of properly setting a status
bit.
Kevin McCarthy [Fri, 22 Sep 2017 18:12:25 +0000 (11:12 -0700)]
Close the imap socket for the selected mailbox on error.
The new $imap_poll_timeout calls the cmd_handle_fatal() error handler
on timeout, which is supposed to close and cleanup.
However, for the currently selected mailbox, the error handler was not
closing the socket after closing up the mailbox. This left extra
SSL/GnuTLS data around and was causing errors on an attempt to
reconnect.
Kevin McCarthy [Fri, 22 Sep 2017 18:07:27 +0000 (11:07 -0700)]
Fix imap sync segfault due to inactive headers during an expunge. (closes #3971)
Mutt has several places where it turns off h->active as a hack. For
example to avoid FLAG updates, or to exclude from imap_exec_msgset.
Unfortunately, when a reopen is allowed and the IMAP_EXPUNGE_PENDING
flag becomes set (e.g. a flag update to a modified header),
imap_expunge_mailbox() will be called by imap_cmd_finish().
The mx_update_tables() would free and remove these "inactive" headers,
despite that an EXPUNGE was not received for them. This would result
in memory leaks and segfaults due to dangling pointers in the
msn_index and uid_hash.
There should probably be a more elegant solution, removing the initial
hacks. However, this is causing a segfault, and the best solution
right now is to turn active back on for non-expunged messages in
imap_expunge_mailbox().
Extra thanks to chdiza, who bravely runs tip and found this issue
quickly.
Kevin McCarthy [Wed, 13 Sep 2017 22:48:16 +0000 (15:48 -0700)]
Change imap copy/save and trash to sync flags, excluding deleted. (closes #3966) (closes #3860)
imap_copy_messages() uses a helper to sync the flags before performing
a server-side copy. However, it had a bug that the "deleted" flag on
a local message, if set, will be propagated to the copy too.
Change the copy sync helper to ignore the deleted flag. Then, change
the imap trash function to use the same helper.
Thanks to Anton Lindqvist for his excellent bug report, suggested
fixes, and help testing.
Kevin McCarthy [Wed, 13 Sep 2017 22:48:13 +0000 (15:48 -0700)]
Remove \Seen flag setting for imap trash. (see #3966) (see #3860)
Commit 323e3d6e5e4c has a side effect where spurious FETCH flag
updates after setting the \Seen flag can cause a sync to abort.
Remove manually setting \Seen for all trashed message before copying.
The next commit will change the imap trash function to use the same
code as the imap copy/save function for syncing the message before
server-side copying.
Kevin McCarthy [Sat, 2 Sep 2017 16:36:52 +0000 (09:36 -0700)]
Fix the new certificate prompt translations.
The Esperanto, Dutch, and Czech po files weren't updated in time for
1.9. Fix the certificate prompt translations by adding a "(s)kip"
choice. Otherwise the prompts would not be functional.
Kevin McCarthy [Fri, 11 Aug 2017 16:04:48 +0000 (09:04 -0700)]
Fix parent_hdr usage in mutt_attach_reply(). (see #3728)
If the selected attachments are not messages and no (common) parent is
found, parent_hdr is set to the passed in hdr. In that case, parent
will still be NULL, but parent_hdr and parent_fp will be set.
Change the test to parent_hdr being NULL, not parent, to check for
this case.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:28 +0000 (18:18 -0700)]
Add edit-content-type helper and warning for decrypted attachments. (closes #3728)
Regenerating the actx index will overwrite any changes made to a
decrypted attachment. Change the mutt_edit_content_type() function to
return 1 when a structural change is made. Add a warning message when
that is the case and a decrypted message was edited, so the user is
not surprised.
Note: mutt_edit_content_type() appeared to regenerate multipart
subparts every time, leading to a memory leak. I believe this was an
oversite, and it should have regenerated only when there were no
subparts, so have "fixed" this.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:25 +0000 (18:18 -0700)]
Fix shared attachment functions. (see #3728)
With nested decryption, the correct FP is associated with the
ATTACHPTR entry. Also, the BODY entries are not continguous, so the
functions need to iterate over the actx index, not the BODY structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:20 +0000 (18:18 -0700)]
Add helpers to add and remove actx entries. (see #3728)
Use the helper in compose update_idx(), to consolidate the resize
logic and simplify the code.
Separate out the actx "free" routine from a routine to empty out the
idx. The index regeneration routines should flush and rebuild the
index without having to renerate the actx structure.
Kevin McCarthy [Fri, 11 Aug 2017 01:18:18 +0000 (18:18 -0700)]
Create ATTACH_CONTEXT to hold attachment index. (see #3728)
Move the idx and idxlen into ATTACH_CONTEXT. In subsequence patches,
this structure will hold more useful items, such as the virtual index.
The swap out is straightforward, except for:
* update_idx() in compose.c, which post-increments the idxlen in the
call and again in the function.
* mutt_gen_attach_list() which doesn't need to returns the new values.
Kevin McCarthy [Sun, 23 Jul 2017 02:48:50 +0000 (19:48 -0700)]
Add $imap_poll_timeout to allow mailbox polling to time out.
Enable the polling flag for the NOOP in imap_check_mailbox(), the
STATUS command in imap_buffy_check(), and the LOGOUT command.
This is not intended to handle all blocking-IO related issues.
However, the periodic NOOP and STATUS are the most frequent places for
mutt to freeze up, especially after a laptop is sleep/woken.
Since these are quick operations with little data, this is a good place
to check if the connection is still working before hanging on a read.
Kevin McCarthy [Fri, 21 Jul 2017 00:30:05 +0000 (17:30 -0700)]
When guessing an attachment type, don't allow text/plain if there is a null character. (see #2933)
Type text/plain should not contain any null characters. Slightly
improve the type guesser by forcing an attachment with any null
characters to be application/octet-stream.
Note the type guesser could use much more improvement, but this is an
easy and obvious fix.
Kevin McCarthy [Wed, 19 Jul 2017 21:04:39 +0000 (14:04 -0700)]
Change imap_cmd_start() to return OK when the cmd_queue is finished. (closes #3956)
Some response handlers can end up recursively calling
imap_cmd_start(), processing all the command completions. If the
outer call was an imap_exec(), this would result in the loop never
being terminated (or just blocking reading a server that has already
finished all the commands).
Change the callers that are simply using it to read a response,
without having called cmd_start(), to check for IMAP_CMD_OK instead.
Currently this is just the open connection function.
When using alloca(), the built-in regexp library limited the failure
stack to 20,000 entries. This value is too large, and causes alloca()
to segfault in the example provided in the ticket.
Decrease the limit to 8000.
Thanks to Thorsten Wißmann for the excellent bug report, which made
debugging this much easier.
Kevin McCarthy [Wed, 12 Jul 2017 19:38:22 +0000 (12:38 -0700)]
Fix crash when $postponed is on another server.
imap_mxcmp() translates NULL to "INBOX". When $postponed points to a
URL with an empty or "INBOX" path, this will end up matching against a
NULL idata->mailbox in imap_status(). This resulted in a crash
because idata->ctx is also NULL.
Thanks to Olaf Hering for the detailed bug report and suggested fix.